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
pj_27pj_27 

Trigger on Campaignmember

Hi,

 

I am writing a trigger on campaignmember where I need to find if a campaignmember was added to a diffrent campaign in past 60 days.

if the campaignmember was not added to a diffrent campagin in past 60 days I need to update the owner of the assiciated lead's or contact's owner to the particular user.

 

1. I am not sure how to achive this - can anyone please guide me on this ?

 

2.Is this a correct object to write a trigger and accomplish this requirement ?

 

3. Also I ran a report  in which there is a field - 'Member First Associated date'. is this a standard field on campaign/ campaignmember ? if yes then is it a created date ?

 

Please suggest.

 

Thanks in advance,

pj_27

 

pj_27pj_27

 

Any thoughts guys ?

 

can any one tell me how can I determine if a lead or contact (campaignmember) is associated with multiple campaigns.is there any piece of code avaialble can help me for my trigger ?

dmchengdmcheng

Yes, you need to write beforeinsert  trigger on CampaignMember.  You would retrieve a list of Contacts and their related CampaignMember records (via SOQL relationship query)  based on the Contact IDs in CampaignMember records and limited by your time period.  Then you loop through the contacts and do the necessary actions. 

 

Same process for Leads.