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
RajashriRajashri 

Illegal assignment from LIST<CampaignMember> to LIST<CampaignMember> at line 6

Hi,

I am getting the error  "Illegal assignment from LIST<CampaignMember> to LIST<CampaignMember> at line 6 "

Can nyone please help?



public with sharing class CampaignMemController {

    public Campaign camp {get; set; }
    list<contact> con = [SELECT id FROM contact];
    
    list<campaignmember> cmlist = [SELECT id, contactid FROM campaignmember];
    list<contact> conlist = new list<contact>();
     public CampaignMemController(ApexPages.StandardController controller) {
         camp  = (Campaign)controller.getRecord();
  
  
    for(campaignmember cm : cmlist)
{
     for(contact c : con)
    {
             if(c.id == cm.contactid)
                              conlist.add(c);
     }
    
//System.debug('All the campaignmemebers under contact '+con.name+'are'+camList );
        }  
    } 

}
PratikPratik (Salesforce Developers) 
Hi Rajashri,

I tried it and it's getting save without any error.

Thanks,
Pratik
RajashriRajashri
Hi Pratik,

Thanks a lot!

i am still getting an error...

Illegal assignment from LIST<CampaignMember> to LIST<CampaignMember> for this line

list<campaignmember> cmlist = [SELECT id, contactid FROM campaignmember];

Can you please copy and paste your code?
pooja kadampooja kadam
Hi Rajashri,
Use CampaignMember instead campaignmember in the line where you are getting error and let me know if it works?

 
RajashriRajashri
Hi Pooja,

I tried that but still i am getting an error..

Thanks
RajashriRajashri
Hi Pratik,

I am trying to print the campaign members in VF page and i am getting an error

Unknown Property  "Unknown property 'CampaignStandardController.cm'"

Can you please help?

<apex:page StandardController="Campaign"  extensions="CampaignMemController">
    <apex:form >
        <apex:pageBlock title="Campaign Members Details" mode="maindetail">
            <apex:pageBlockSection title="Campaign Members"  id="cm3">
                <apex:pageblocktable value="{!cm}" var="lead">
                        <apex:column headerValue="Name">
                            <apex:outputfield value="{!lead.Id}" />
                        </apex:column>
    
   </apex:pageblocktable>
                      </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
PratikPratik (Salesforce Developers) 
Hi Rajashri,

The issue is, you are using variable name insted of method name. The "cm" is variable in your class, for now i have put it as "camp" as it's method in the below bold part. 


<apex:page StandardController="Campaign"  extensions="CampaignMemController">
    <apex:form >
        <apex:pageBlock title="Campaign Members Details" mode="maindetail">
            <apex:pageBlockSection title="Campaign Members"  id="cm3">
                <apex:pageblocktable value="{!camp}" var="lead">
                        <apex:column headerValue="Name">
                            <apex:outputfield value="{!lead.Id}" />
                        </apex:column>
    
   </apex:pageblocktable>
                      </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>


Hope this will help you to resolve your issue.

Thanks,
Pratik
RajashriRajashri
Thanks Pratik..ID field is coming fine but i want to display the Contact Id and other fields from campaign list..

How can i do that?