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
tschatztschatz 

Populate an Account Field when a Contact is added to a Campaign

Hi All,
 
I have created a trigger and class that populates a field on the Account when a Contact is edited, but I really want this to be triggered when a Contact is added to a Campaign.
 
I tried adding a trigger to the CampaignMembership object but it tells me that triggers can't be added to this object.
 
Which object should I add the trigger to in order to update the Account field when a Contact is added to a Campaign?
 
I guess the question could also be, is a Contact added to a  Campaign or is a Campaign added to a Contact?
 
Thanks in advance.
 
_t
Ron HessRon Hess
If the questing is : is a Contact added to a  Campaign or is a Campaign added to a Contact?

then the answer is neither, a contact id and a campaign id are added to a campaign member object, allowing the relationship to be many -to many.

Since you cannot add triggers to CampaignMember object, there is no option to run code when a contact is added to a campaign.

you may be able to do this with a webservice and an external process, or a button on the campaign or contact that will perform the updates.