You need to sign in to do that
Don't have an account?
kim.stites
Update Contact from CampaignMember trigger
I am trying to update the contact with the most recent campaign id from the campaignmember table but I am missing something.
trigger Update_Contact_Recent_Campaign on CampaignMember (after insert,after update) { List<Contact> myContactUpdate = [SELECT CampaignId FROM CampaignMember WHERE ContactID <> 'null' order by SystemmodStamp desc limit 1]; Recent_Campaign_ID__c = CampaignId update myContactUpdate;
try to use campaignid instead od id in this
myContactUpdate.Recent_Campaign_ID__c = campaignMember.get(0).campaignid;
i hopw it will work
All Answers
I did not get this query you are getting list of contact but querying CampaignMember, are you able tpo compile it.?
No I want to get the most recent campaign when a campaignmember is updated or inserted and take that campaign id and update a field on the contact table called most recent campaign id.
Try this
Thank you so much!!
This is giving me the campaignmember Id and I want the campaign Id. I tried changing it to campaignMember.get(0).CampaignId but that errors out. Any thought?
try to use campaignid instead od id in this
myContactUpdate.Recent_Campaign_ID__c = campaignMember.get(0).campaignid;
i hopw it will work