• rajafu
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 3
    Replies
Hi all,

I have build visualforce pages for force.com site to show case our products on website.

Everything is fine but when i search a product on google search i am not able to find the product which we are displaying on our website.

Is there any process or additional code required  for search. plz help

Thank you.

Hi All, I am trying to fetch the list of fields for a custom object.. below is the code

String fieldNames = Field_Details.getFieldDetails('Inspection_Checklist__c');

my object definition is as

Singular Label -- Inspection Checklist
Plural Label -- Inspection Checklist
Object Name -- Inspection_Checklist
API Name -- Inspection_Checklist__c

I tried passing all possible values but it not returning anything. same code iis working for another Custom Object... Am i missing any thing.. please help

Thanks

 

Please help in code coverage. im able to get 34% code coverage . 

 

Please find the below code class and test class.

 

Thanks...

 

 

1

  public with sharing class NewOrderPageClass

 2

  {

 3

    public Id orid{get;set;}

 4

    // public List<id> Opids{get;set;} 

 5

    public Order__c OppId{get;set;}

 6

    public List<Order_Product__c> oplist{get;set;}

 7

    public List<Product_Master__c> Pmid{get;set;}

 8

    public NewOrderPageClass(ApexPages.StandardController controller)

 9

    {

 10

    try

 

    {

 

     String orid=ApexPages.CurrentPage().getParameters().get('id');

 

    

 

     oplist=new List<Order_Product__c>();

 

     OppId=[select id,name from Order__c where id=:orid];

 

          Pmid=[select id,name,Size_S__c,Size_L__c,Size_M__c,Size_XL__c,Price__c,Remarks__c   from Product_Master__c WHERE Product_Type__c='Sales' ORDER BY CreatedDate ASC];

 

       

 

     }

 

     

 

    catch(Exception e)

 

    {

 

    system.debug(e);

 

    }

 

    }

 

      public PageReference CreateOrderProduct()

 

          {

 

   

 

       for( Product_Master__c p:pmid)

 

           {

 

           try

 

           {

 

           if(p.Size_S__c>0||p.Size_L__c>0||p.Size_M__c>0||p.Size_XL__c>0)

 

           {

 

            RecordType rty = [SELECT Name, id FROM RecordType WHERE sObjectType='Order_Product__c' and name='Sales'];

 

            System.debug('-------------------> Record Type Ids'+rty);

 

             Order_Product__c op=new Order_Product__c(RecordTypeId=rty.id);

 

              

 

               op.Product_Master__c=p.id;

 

               op.Sales_Order__c=OppId.id;

 

               op.name=p.Name;     

 

                op.Size_S__c=p.Size_S__c;

 42

                op.Size_M__c=p.Size_M__c;

 43

                op.Size_L__c=p.Size_L__c;

 44

                op.Size_XL__c=p.Size_XL__c;

 45

                /*op.quantity__c=p.Quantity__c;*/

 46

                insert op;

 47

                System.debug('-------------------> Order Products are Ids'+op);

 48

               oplist.add(op);

 49

             

 50

                   

 51

          }

 52

          }

 53

          catch(Exception e)

 54

          {

 55

          system.debug(e);

 56

          }

 57

          }

 58

        PageReference reference=new PageReference('/'+OppId);

 59

         

 60

          return reference;

 61

         }

 62

    

 63

      private Static testmethod void  NewOrderPageClass()

 64

      { 

 65

         List<Order_Product__c> oplist=new List<Order_Product__c>();

 66

          Account a=new Account();

 67

          a.name='ravi';

 68

          insert a;      

 69

          Order__c o=new Order__c();     

 70

          o.Account__c=a.id;      

 71

          insert o;    

 72

          List<Product_Master__c> pmList=new List<Product_Master__c>();

 73

          Product_Master__c pm = new Product_Master__c (Name='ravi',Size_S__c=12,Size_M__c=13,Size_L__c=14,Size_XL__c=15,Product_Type__c='Sales');

 74

          pmList.add(pm);

 75

          /*pm.Name='ravi';

 76

          pm.Size_S__c=12;

 77

          pm.Size_M__c=13;

 78

          pm.Size_L__c=14;

 79

          pm.Size_XL__c=15;*/

 80

          insert pm;        

 81

          Order_Product__c op=new Order_Product__c();     

 82

          op.Product_Master__c=pm.id;

 83

          op.Sales_Order__c=o.id;

 84

          op.name=pm.Name;      

 85

          op.Size_S__c=11;

 86

          op.Size_M__c=12;

 87

          op.Size_L__c=14;

 88

          op.Size_XL__c=15 ;         

 89

          insert op;            

 90

          NewOrderPageClass atc= new NewOrderPageClass(new ApexPages.StandardController(o));                  

 91

          PageReference pageRef = Page.SalesOrder;

 92

         Test.setCurrentPage(pageRef);

 93

        /* atc .CreateOrderProduct();*/

 94

   

 95

      }

 96

         

 97

  }

 

 

 

 

  • September 16, 2013
  • Like
  • 0

Hi all,

 

I have three Objects Campaigns, Campaign Members and Contacts all are custom Objects.

 

Campaign member is junction object for Campaigns and Contacts.

 

Functionality - At first i will create a campaign record, under campaign record related list i have a visualforce button called Add Contacts so when i click that i i will be seeing all the contacts with check boxes. Next step is i will select some contacts and click process selected button so the selected contacts should add to the campaign members to the certain Campaign.

 

Similar to standard  Campain, Campaign Members functionality.

 

Error: In the below mention code im able to get all the contacts and saves to campaign Members (process method in class), but im not able to add the selected records to the certain Campaign. 

 

CODE:

 

Visualforce page:

 

<apex:page controller="PagingController">
<apex:form >
  <apex:sectionHeader title="Campaign Membership Manager" description="Add Contacts to Campaigns"/>
          <apex:pageblock >
      <apex:pageBlockButtons location="top">
        <apex:commandButton action="{!process}" value="Process Selected"/>
        <apex:commandButton action="{!cancel}" value="Cancel"/>
      </apex:pageBlockButtons>
      <apex:pageMessages />
 
      <apex:pageBlockSection title="Category Results -  Page #{!pageNumber}" columns="1">
        <apex:pageBlockTable value="{!categories}" var="c">
          <apex:column width="25px">
            <apex:inputCheckbox value="{!c.checked}"/>
          </apex:column>
          <apex:column value="{!c.Obj.Name}" headerValue="Name"/>
        </apex:pageBlockTable>
      </apex:pageBlockSection>
    </apex:pageBlock>
 
    <apex:panelGrid columns="4">
    <apex:commandLink action="{!first}">First</apex:commandlink>
    <apex:commandLink action="{!previous}" rendered="{!hasPrevious}">Previous</apex:commandlink>
    <apex:commandLink action="{!next}" rendered="{!hasNext}">Next</apex:commandlink>
    <apex:commandLink action="{!last}">Last</apex:commandlink>
    </apex:panelGrid>
   </apex:form>
</apex:page>

 Apex Class:

 

public with sharing class PagingController {

  
    List<CobjectsWrapper> cobj {get;set;}
    public Campaign__c camp{get;set;}
   // private List<Campaign_Member__c>  campaignMemberList { get; set; }  
    //private List<Campaign_Member__c>  pageCampaignMemberList;  
    private String  selectedCampaign;
    public boolean bAdd;
    public String  messageTitle             { get; set; }
    public String  messageDetail            { get; set; }
    public String  messageSeverity          { get; set; }
    transient public Boolean messageShow    { get; set; }
    // instantiate the StandardSetController from a query locator
    public ApexPages.StandardSetController con {
        get {
            if(con == null) {
                con = new ApexPages.StandardSetController(Database.getQueryLocator([Select Id, Name from Lead_Contact__c  Order By Name limit 100]));
                // sets the number of records in each page set
               system.debug('Controllerleadcontact'+con);
                con.setPageSize(2);
            }
            return con;
        }
        set;
    }
 
    // returns a list of wrapper objects for the sObjects in the current page set
    public List<CobjectsWrapper> getCategories() {
  //  if(cobj== null)
   // {
        cobj = new List<CobjectsWrapper>();
        for (Lead_Contact__c lobj : (List<Lead_Contact__c>)con.getRecords())
            cobj.add(new CobjectsWrapper(lobj));
           system.debug('LeadContactWrapper' + cobj);
    //    }'
        return cobj;
    
    }
    public List<SelectOption> getCampaigns(){
        
        List<SelectOption> options  = new List<SelectOption>();
        List<Campaign__c> cList        = new List<Campaign__c>();
        
        try {
            cList = [ SELECT Id, Name, Description__c FROM Campaign__c WHERE Status__c = 'Planned' AND Active__c = true ORDER BY Name ];
            for( Campaign__c  c: cList ){
                options.add( new SelectOption( c.Id, c.Name ) );
            }
            
            if( cList == null || cList.size() <= 0 ){
                // Show Info Message that no records have been found
                messageTitle    = 'No data';
                messageDetail   = 'No Campaign';
                messageSeverity = 'info';
                messageShow     = true;
                
                return null;    
            }else{
                return options;
            }        
        }catch( Exception ex ){
           // Show error Message with severity FATAL
           // messageTitle  = 'CMM_Error';
           // messageDetail     = ex.getMessage();
           //messageSeverity = 'fatal';
           //messageShow    = true;
           return null;
        } 
    }
    public String getSelectedCampaign(){
   
     return this.selectedCampaign;
    }
      public void setSelectedCampaign( String selectedCampaign ){
        this.selectedCampaign = selectedCampaign;
    }   
    // displays the selected items
    public PageReference process() {
    List<Campaign__c> camp1=[select Name,Id from Campaign__c  WHERE  Active__c = true];
    system.debug('Campaign'+camp1);
    List<Lead_Contact__c > selectedObjects = new List<Lead_Contact__c >();
        for (CobjectsWrapper cw : cobj) {
            if (cw.checked == true){
            selectedObjects.add(cw.Obj);
                ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'changes  saved sucessfully'));
                }
        }
        List<Campaign_Member__c> SavedDBO = [Select  Name,Lead_Contact__c,Campaign__c from Campaign_Member__c where Lead_Contact__c=:selectedObjects  ];
             //system.debug('Campaign'+SavedDBO.Campaign);
             system.debug('LeadContact '+SavedDBO);
             List<Campaign_Member__c> SEDBO = new List <Campaign_Member__c>();
            for(Lead_Contact__c Obj1 : selectedObjects) {
             bAdd = TRUE;

                
                for (Campaign_Member__c DBObj : SavedDBO) {
                    system.debug('CampaignMember%%%%%%%%%%%%%%%%'+DBObj);
                    if (SavedDBO.size() > 0)
                    {
                        // if the IDs match
                        if (Obj1.ID == DBObj.ID) {
                           // Do not save
                            bAdd = FALSE;
                        }
                    }
                    
                    
                  /*  for(Campaign__c cmp :camp1)
                    {
                    system.debug('CAMP&&&&&&&&&&&&&&&'+cmp);
                    if(DBObj.ID == cmp.ID)
                    {
                       system.debug('campaign'+DBObj.ID);
                       bAdd=FALSE;
                       }
                       }*/
                }

                if (bAdd) { 
                    // use SEDBO to add selected rows to object
                    // add one Campaign member row per LeadContact record if bAdd = TRUE
                    SEDBO.add(new Campaign_Member__c(Lead_Contact__c=Obj1.Id,Name=Obj1.Name));
                     
                  //  SavedDBO.add(DBObj);
                       system.debug('Contacts######################' +SEDBO);
                }

            }
            insert SEDBO;
        return null;
    }
  
    // indicates whether there are more records after the current page set.
    public Boolean hasNext {
        get {
            return con.getHasNext();
        }
        set;
    }
 
    // indicates whether there are more records before the current page set.
    public Boolean hasPrevious {
        get {
            return con.getHasPrevious();
        }
        set;
    }
 
    // returns the page number of the current page set
    public Integer pageNumber {
        get {
            return con.getPageNumber();
        }
        set;
    }
 
    // returns the first page of records
    public void first() {
        con.first();
    }
 
    // returns the last page of records
    public void last() {
        con.last();
    }
 
    // returns the previous page of records
    public void previous() {
        con.previous();
    }
 
    // returns the next page of records
    public void next() {
        con.next();
    }
 
    // returns the PageReference of the original page, if known, or the home page.
    public void cancel() {
        con.cancel();
    }
    
    public class CobjectsWrapper {
 
    public Boolean checked{ get; set; }
    public Lead_Contact__c Obj{get; set;}
 
    public CobjectsWrapper(){
        Obj = new Lead_Contact__c();
        checked = false;
    }
 
    public CobjectsWrapper(Lead_Contact__c lc){
        Obj = lc;
        checked = false;
    }
 
}
}

 Thanks in advance........

 

  • December 18, 2012
  • Like
  • 0

I have a custom object called Demo Booking (DB).

I have another custom object as a related list called Demo Booking Object (DBO).

 

DBO is related to DB and to another table called Demo Object (DO). Demo objects are items that we use in our demo. They have a type and a minutes.

 

For clarity:

DBs are the BOOKINGS. DO are the OBJECTS and DBOs are the link between the two (like Opportunities, Products and Opportuntiy Products)

 

The user has to create a new Booking (DB). Once they have done that they have to select the Objects (DO) using the DBO related list. This uses the standard SFDC "Search" then "Save and New" method. The issue is that most Sales people do not really know these objects and searching for them is clunky.

 

I created a new visulaforce page on top of the DO object which displays the Objects along with their name and a checkbox.

 

The idea being that they open the new page from their new Booking and can just check the box next to the items to associate Booking#1 with Objects #1,2,3,5,6,9.

 

Finally: DBO rolls up the selected DOs' minutes to give us an approximate time for the demo.

 

If I go to the apex page this display correctly.

 

 

public class DemoObjectsShowAll{
     
        //Collection of the class/wrapper objects cObject
        public List<cObjects> objectList {get; set;}
     
        //This method uses a simple SOQL query to return a List of Objects
        public List<cObjects> getAllDemoObjects() {
            if(objectList == null) {
                objectList = new List<cObjects>();
                for(SE_Demo_Objects__c d :    [SELECT Name, Minutes_for_Demo__c, Product_Type__c FROM SE_Demo_Objects__c LIMIT 50]) {
                    // As each object is processed we create a new demo object and add it to the ObjectList
                    objectList.add(new cObjects(d));
                }
            }
            return objectList;
        }
     
     
        public PageReference processSelected() {
     
                    //We create a new list of Objects that we be populated only with Objects if they are selected
            List<SE_Demo_Objects__c> selectedObjects = new List<SE_Demo_Objects__c>();
     
            //We will cycle through our list of cObjects and will check to see if the selected property is set to true, if it is we add the Objects to the selectedObjects list
            for(cObjects cObj : getAllDemoObjects()) {
                if(cObj.selected == true) {
                    selectedObjects.add(cObj.Obj);
                }
            }
     
            // Now we have our list of selected objects
            System.debug('These are the selected Objects...');
            for(SE_Demo_Objects__c Obj : selectedObjects) {
                system.debug(Obj);
            }
            return null;
        }
     
     
        // This is our wrapper/container class. 
        public class cObjects {
            public SE_Demo_Objects__c Obj{get; set;}
            public Boolean selected {get; set;}
     
            //This is the contructor method. 
            public cObjects(SE_Demo_Objects__c d) {
                Obj = d;
                selected = false;
            }
        }
    }

 

<apex:page Controller="DemoObjectsShowAll" sidebar="false">
    <apex:form >
        <apex:pageBlock >
            <apex:pageMessages />
            <apex:pageBlockButtons >
                <apex:commandButton value="Add items to your Demo" action="{!processSelected}" rerender="table"/>
            </apex:pageBlockButtons>

            <apex:pageBlockTable value="{!allDemoObjects}" var="demo">

                <!-- This is our selected Boolean property in our wrapper class -->
                <apex:column >
                    <apex:inputCheckbox value="{!demo.selected}"/>
                </apex:column>
                <!-- This is how we access the values within our container/wrapper -->

                <apex:column value="{!demo.obj.name}"/>
                <apex:column value="{!demo.obj.Minutes_for_Demo__c}"/>
                <apex:column value="{!demo.obj.Product_Type__c}"/>
            </apex:pageBlockTable>      
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

Now - I want to associate this with my related list and, of course, it doesn't associate because it is not a standard controller. How do I fix this?

 

The way I see it I have 2 issues:

#1 is that I need to write the the DBO rows from this page so I will need to associate them with the DB ID. (I have not done this as I wanted to do #2 first)

#2 This page needs to plug into the NEW button on the DBO related list on DB but it is related to DO.

 

 

Hi All,

 

I have a request to auto-number opportunities based on a custom field, business unit. Eg.:

SSA-001

BTE-001

SSA-002

NTE-001

SSA-003 etc

 

I have a cutom object that will hold these numbers and increment based on the business unit in the Opportunity.  This object has no relation (link) to the Opportunity object.  I am currently updating a field on the Opportunity, based on the business unit.  I am currently hitting governor limits when I mass import opportunities.  Please assis urgently.  Herewith my code below:

 

public with sharing class AutoNumberHolder {

public static void display(Opportunity [] oppr){

      Integer m;

 

//List<Opportunity> oppList = new List<Opportunity>();

for( Opportunity o: oppr){

          if(o.Business_Unit__c=='Bateman Engineering (SSA)'){

              AutoNumberHolder__c n =[select id, opportunity__c, Num1__c, num2__c from AutoNumberHolder__c ];

              m=n.Num1__c.intValue();

              m=m+1;

              o.Test_Num__c=m;

              n.Num1__c=m;

 

                  update n;

        }

 

      if(o.Business_Unit__c=='Bateman Engineering (AUS)'){

                  AutoNumberHolder__c n =[select id, opportunity__c, Num1__c, num2__c from AutoNumberHolder__c ];

                  m=n.Num2__c.intValue();

                  m=m+1;

                 o.Test_Num__c=m;

                 n.Num2__c=m;

 

                  update n;

        }

 

 

     }

   }

}

 

Here’s the Trigger:

 

trigger UpdateAutoNumber on Opportunity (before insert,

before update) {

      if(Trigger.isInsert){

 

Opportunity [] oppr =Trigger.new;

                  AutoNumberHolder.display(oppr);

 

}

if(Trigger.isUpdate){  

 

for (Integer i = 0; i < Trigger.new.size(); i++)    {

 

if (Trigger.new[i].business_unit__c != Trigger.old[i].Business_Unit__c){

      Opportunity [] oppr = Trigger.new;

   AutoNumberHolder.display(oppr); 

   }

 

 } 

 

Much appreciated.

  • March 25, 2011
  • Like
  • 0