function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Div403Div403 

Hi all,

I am recieving the following error message when trying to load records in vf page

"List controllers are not supported in Campaign Members"

Can anyone knows the solution for the above error? Please help us.

Thanks in advance
srlawr uksrlawr uk
Hi Div403,

Unfortunately the error message you are getting is quite right, there is no standard list controller for the joint object CampaignMember. You will have to roll your own soltion using a custom apex controller, and try to replicate the bits of functionality you are after in your own apex.

Sadly this is fairly time consuming (the first time round) and also imposes limits on your work that the list controllers don't suffer so badly.

If you are after a pagination process, you will need to write your own "Next" and "Previous" links on the page, which connect to action methods in your controller that re-run your query with various values of OFFSET in the SOQL (which you can read up on here http://www.salesforce.com/us/developer/docs/soql_sosl/Content/sforce_api_calls_soql_select_offset.htm) and then rerender the table with different snapshots over your data. (doing this is better than loading all you rows and trying to navigate them on the page due to heapsize and query limits).

This page on the developer docs covers building a custom list controller quite well. I hope it's of use!
https://www.salesforce.com/us/developer/docs/pages/Content/pages_custom_list_controller.htm


Div403Div403
Hi,

Thanks for the reply.

Here is my apex controller and visualforce page.

Do i need to change any thing else? Please advice.

Apex Controller

public with sharing class pagingController {


public ApexPages.StandardSetController con {
  get {
   if(con == null)
   {
    con = new ApexPages.StandardSetController( Database.getQueryLocator([ Select Id FROM CampaignMember Order By Id]));

    con.setPageSize(5);
   }
   return con;
  }
  set;
}

public List<CampaignMember> getContacts() {
  return (List<CampaignMember>) con.getRecords();
}

public Boolean hasNext {
  get {
   return con.getHasNext();
  }
  set;
}


public Boolean hasPrevious {
  get {
   return con.getHasPrevious();
  }
  set;
}


public Integer pageNumber {
  get {
    return con.getPageNumber();
  }
  set;
}


public void first() {
  con.first();
}


public void last() {
  con.last();
}


public void previous() {
  con.previous();
}


public void next() {
  con.next();
}


public void cancel() {
  con.cancel();
}

}

Visualforce Page

<apex:page controller="pagingController">
  <apex:pageBlock title = "Camapign members">
  <apex:pageBlockSection title="list of Campaign Members">
  <apex:pageBlockTable title="Camapign memebers in System" value="{!Campaignmembers}" var="c" >
  <apex:outputField value="{!c.Id}" title=" Id value"/>
  <apex:outputField value="{!c.Status}" title=" Status value"/>
  <apex:outputField value="{!c.ContactId}" title=" Status value"/>
  </apex:pageBlockTable>
  </apex:pageBlockSection>


  </apex:pageBlock>

</apex:page>