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
andy_candy_c 

getContactId() from Campaignmember returns null

Retrieving Campaignmembers via a query and then attempting to get the contactId from the resulting Campaignmembers returns null.

I have a query that correctly returns 3 Campaignmembers but calling getContactId() against them returns null.

Is anyone succesfully using Campaignmember.getContactId()?
DevAngelDevAngel

Hi andy_c,

Can you post your SOQL statement?  Also, campaignMembers can be Leads as well, in which case that campaign member would not necessarily have a Contact Id. 

andy_candy_c
Bingo!

Yes, that is it - they are Leads not Contacts.

Thank you for your help.