You need to sign in to do that
Don't have an account?
Adding person account as campaign member
Hi,
I want to add person account to campaign as campaign member using apex, but was not able to find out the way to pass account id in campaign member object.
Since i read through some blogs that person account is treated as contact in SF so i passed accountid to contactId field of CampaignMember object. But got the "FIELD_INTEGRITY_EXCEPTION, Contact ID: id value of incorrect type: 001P000000XhJYkIAN: [ContactId]" error
My code is as below -
CampaignMember cm=new CampaignMember(CampaignId='701P00000001sWP',contactId='001P000000XhJYk',Status='Sent');
insert cm;
So hw i would pass person account id to CampaignMember object..?
Hi , know its a late reply, but just in case someone else needs this solution:
PersonAccount entity has 2 Ids : Id and PersonContactId. It is the value of PersonContactId you need to pass to the ContactId property in CampaignMember .
Code:
var qr=sforceService.query("SELECT Id, PersonContactId FROM Account where Id = '001f00000076hzq'");
var personContactId = qr.records[0].Any[1].InnerText;
CampaignMember cm=new CampaignMember(CampaignId='701P00000001sWP',contactId='personContactId',Status='Sent');
insert cm;