2

enter image description here

I am trying to query with CampaignMemberStatus object and getting this error:

Illegal assignment from List CampaignMemberStatus> to List CampaignMemberStatus>

Query:

List <CampaignMemberStatus> lst=new List<CampaignMemberStatus>();
lst=[SELECT CampaignID,label FROM CampaignMemberStatus];
3
  • if possible provide screenshot pf error you are getting. Commented Dec 30, 2015 at 10:17
  • @Tushar Sharma I have added screenshot
    – devsfdc
    Commented Dec 30, 2015 at 10:25
  • @devsfdc check is there any apex class created with name CampaignMemberStatus ?
    – Ratan Paul
    Commented Dec 30, 2015 at 10:39

2 Answers 2

5

I tried the code in Developer console and its working fine. The error might be because of below reason

  • If there is any apex class with the same name of the standard or global sObjects while creating List, map,set the above error will reflect.

We can solve this problem in two ways:

  1. We have to rename our Apex Class to some other name.

  2. Use 'Schema' before sObject while creating List, Set, Map (Don't use 'schema' before sObject in SOQL Query)

1
  • Yes...That'works!
    – devsfdc
    Commented Dec 30, 2015 at 10:49
1
List<CampaignMemberStatus> lst=new List<CampaignMemberStatus>();
 lst=[SELECT CampaignID,label FROM CampaignMemberStatus];

I test this code and it is working perfectly. test it

2
  • 1
    Same here, tested in Developer console and works fine !
    – SF_user
    Commented Dec 30, 2015 at 10:03
  • tested again.continue to get the error.Is there any setting or anything that i might be missing.
    – devsfdc
    Commented Dec 30, 2015 at 10:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .