I'm confused with LeadId
and ContactId
fields, these are contacts or leads associated with a campaign, to my understanding, it's who was a prospect (lead or contact) at the moment of associating with campaign. When I run a query:
select count(id) from CampaignMember where LeadId != null and ContactId != null
And… I get a list of CampaignMembers with both lead and contact id fields! How?
In addition, when I join converted leads on CampaignMembers (contactId
and convertedContactId
) I see that some of the associated contacts were leads before, while leadId
is empty. Doesn't make sense. Thanks!
Best Answer
From my experience working with the CampaignMember object, I see the following scenarios:
1.
CampaignMember
withLead
CampaignMember.LeadId
is populatedCampaignMember.ContactId
is null2.
CampaignMember
withContact
CampaignMember.LeadId
is nullCampaignMember.ContactId
is populated3.
CampaignMember
withContact
who is already a convertedLead
CampaignMember.LeadId
is nullCampaignMember.ContactId
is populated4.
CampaignMember
withLead
, thenLead
is converted toContact
CampaignMember.LeadId
is populatedCampaignMember.ContactId
is also populatedIn writing custom logic to determine if I should be using the
Contact
orLead
lookup onCampaignMember
, I first check ifContactId
is populated. If it's not, then I fallback to theLead
.