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
Syed F RazaSyed F Raza 

Error: Invalid Field CampaignID for sObject Lead

HI All,

I am trying to do a standard controller list for Object LEAD. While using Campaign to show as a column in the table, I am getting the following error:

Error: Invalid Field CampaignID for sObject Lead

Since Campaign is a LookUp field, I made Campaign to CampaignID. But the problem presists.

Code I wrote is as follows:
<apex:page sidebar="false" standardcontroller="Lead" recordSetVar="ld1">
    
    <apex:pageBlock title="List of Leads" tabStyle="Lead">
    
        <apex:pageBlockTable value="{!ld1}" var="l1">
        
            <apex:column value="{!l1.Name}" />
            <apex:column value="{!l1.EMail}" />
            <apex:column value="{!11.CampaginID}" />
            <apex:column value="{!l1.CleanStatus}" />
            <apex:column value="{!l1.DandbCompany}" />
            <apex:column value="{!l1.HasOptedOutOfEmail}" />
        
        </apex:pageBlockTable> 
    
    </apex:pageBlock>

</apex:page>

Any suggestions!!
 
Alain CabonAlain Cabon
@Syed F Raza

'CampaignID' field is not accessible on the Lead record

Resolution
User is trying to access CampaignId field from Lead object . This field is not accessible if you query a Lead object using API.

User can get the details by querying CampaignMember object through API. 

Below are few of the useful links: 

https://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_campaignmember.htm  (https://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_campaignmember.htm )

https://developer.salesforce.com/forums/ForumsMain?id=906F00000008xZbIAI