• rajafu
  • 0 Points
  • Member since 2012

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
  • 3
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



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


Please find the below code class and test class.






  public with sharing class NewOrderPageClass




    public Id orid{get;set;}


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


    public Order__c OppId{get;set;}


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


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


    public NewOrderPageClass(ApexPages.StandardController controller)








     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)










      public PageReference CreateOrderProduct()






       for( Product_Master__c p:pmid)












            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);




















                insert op;


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












          catch(Exception e)










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




          return reference;






      private Static testmethod void  NewOrderPageClass()




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


          Account a=new Account();




          insert a;      


          Order__c o=new Order__c();     




          insert o;    


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


          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');














          insert pm;        


          Order_Product__c op=new Order_Product__c();     














          op.Size_XL__c=15 ;         


          insert op;            


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


          PageReference pageRef = Page.SalesOrder;




        /* atc .CreateOrderProduct();*/













  • 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. 




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: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 value="{!c.Obj.Name}" headerValue="Name"/>
    <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 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
            return con;
    // 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;    
                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];
    List<Lead_Contact__c > selectedObjects = new List<Lead_Contact__c >();
        for (CobjectsWrapper cw : cobj) {
            if (cw.checked == true){
                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('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) {
                    if (SavedDBO.size() > 0)
                        // if the IDs match
                        if (Obj1.ID == DBObj.ID) {
                           // Do not save
                            bAdd = FALSE;
                  /*  for(Campaign__c cmp :camp1)
                    if(DBObj.ID == cmp.ID)

                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();
    // indicates whether there are more records before the current page set.
    public Boolean hasPrevious {
        get {
            return con.getHasPrevious();
    // returns the page number of the current page set
    public Integer pageNumber {
        get {
            return con.getPageNumber();
    // returns the first page of records
    public void first() {
    // returns the last page of records
    public void last() {
    // returns the previous page of records
    public void previous() {
    // returns the next page of records
    public void next() {
    // returns the PageReference of the original page, if known, or the home page.
    public void 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) {
            // Now we have our list of selected objects
            System.debug('These are the selected Objects...');
            for(SE_Demo_Objects__c Obj : selectedObjects) {
            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:pageBlockTable value="{!allDemoObjects}" var="demo">

                <!-- This is our selected Boolean property in our wrapper class -->
                <apex:column >
                    <apex:inputCheckbox value="{!demo.selected}"/>
                <!-- 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}"/>


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-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 ];






                  update n;



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

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






                  update n;








Here’s the Trigger:


trigger UpdateAutoNumber on Opportunity (before insert,

before update) {



Opportunity [] oppr =Trigger.new;






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;






Much appreciated.

  • March 25, 2011
  • Like
  • 0