You need to sign in to do that
Don't have an account?

Illegal assignment from List<CampaignMember> to List<CampaignMember>
I was running into this error in some code of mine and so I began to do some troubleshooting. Hoping someone can explain what is going on.
So while troubleshooting, I opened an execute anonymous window to test a theory; this error only appears when referencing CampaignMember and not other objects. Test Code 1 below results in the error "Illegal assignment from List<CampaignMember> to List<CampaignMember>" while test code 2 executes with no errors.
What is the difference and how can get around this issues?
------------Test Code 1:-----------------
string ID='xyz';
list<CampaignMember> lst = new List<CampaignMember>();
lst = [Select id from CampaignMember where id =:ID];
--------------Test Code 2:-----------------
string ID='xyz';
list<Campaign> lst = new List<Campaign>();
lst = [Select id from Campaign where id =:ID];
So while troubleshooting, I opened an execute anonymous window to test a theory; this error only appears when referencing CampaignMember and not other objects. Test Code 1 below results in the error "Illegal assignment from List<CampaignMember> to List<CampaignMember>" while test code 2 executes with no errors.
What is the difference and how can get around this issues?
------------Test Code 1:-----------------
string ID='xyz';
list<CampaignMember> lst = new List<CampaignMember>();
lst = [Select id from CampaignMember where id =:ID];
--------------Test Code 2:-----------------
string ID='xyz';
list<Campaign> lst = new List<Campaign>();
lst = [Select id from Campaign where id =:ID];
All Answers