You need to sign in to do that
Don't have an account?
SBN
How to pass Personaccount id to campaign member
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.
I got the "FIELD_INTEGRITY_EXCEPTION, Contact ID: id value of incorrect type: 001P000000XhJYkIAN: [ContactId]" error.
DO I need to use "Personcontactid" to pass instead of contact id from account object ?
I suspect you may be trying to put a contact id into an account lookup field:
email2HoldingObject.get(aitem.personemail).PersonalAccount__c = aitem.PersonContactId ;
You may want to check that specific line and see if that's where the trigger is erroring out.
Ram
All Answers
Ram
"Apex trigger top1000csv caused an unexpected exception, contact your administrator: top1000csv: data changed by trigger for field PersonalAccount: id value of incorrect type: 003Z000000KwGUMIA3". Do you have any suggestion?
yes. top1000csv is a custom trigger and here is my code below:
for ( Holdingobject_top1000__c Ho : Trigger.new )
{
email2HoldingObject.put( Ho.email__c, Ho ) ;
if ((Ho.email__c != null) && ( ! Hobj_Emails.contains(Ho.email__c) ) )
Hobj_Emails.add(Ho.email__c);
}
list<account> a = [SELECT id, personemail,Member_id__c,PersonContactId from account WHERE personemail in : Hobj_Emails and IsPersonAccount =true] ;
// iterate through the contacts that were found and add them to the set and map used for contacts.
for ( account aitem : a ) {/
email2HoldingObject.get(aitem.personemail).PersonalAccount__c = aitem.PersonContactId ;
}
// Creating the Campaign member for each Hodlign object results.
for ( Holdingobject_top1000__c Ho : Trigger.new )
{
CampaignMember newCM = new CampaignMember(
CampaignId = campid,
LeadId = Ho.lead__c ,
ContactId = Ho.personalaccount__c,
status = 'Attended' );
insert newCM ;
}
I suspect you may be trying to put a contact id into an account lookup field:
email2HoldingObject.get(aitem.personemail).PersonalAccount__c = aitem.PersonContactId ;
You may want to check that specific line and see if that's where the trigger is erroring out.
Ram
yeah.Its referring to the contact id and I created a look up for Account object in my "Holding object" custom object. I created a new look up for contact object with name "Personcontact__c" and passed the personcontactid to this field. and the trigger is now working fine
email2HoldingObject.get(aitem.personemail).Personcontact__c = aitem.PersonContactId ;
Thank you
Ram