You need to sign in to do that
Don't have an account?
lreed
update Campaign Members Custom Field when an Event is added to the campaign
I am looking for the best way to accomplish updating Campaign Members Custom Field when an Event is added to the Campaign.
I don;t think its possible with process flow. Any Trigger examples would be greatly appreciated.
I don;t think its possible with process flow. Any Trigger examples would be greatly appreciated.
You could take the Process a step further, and have it call a Flow:
- The Flow would take an input variable for the Campaign Id (WhatId of th event).
- The Flow would do a Fast Lookup of Campaign Members, where the CampaignId = the input variable in Step 1.
- Create a Loop element and Assignment elements that loop through the Campaign Member sobject collection, and set the custom fields
- Create a Fast Update element to update the campaign members collection variable.
Otherwise you're looking at a trigger that does same logic.Here you go with the trigger code.
Please Modify this sample code as per your requirement. I hope this will help
Thanks,
799 Coder
I placed debug statements in the code and it appears that the line of code to update the field does Not get executed, but looking at the record
in the UI shows it has not been updated.
Hi Ireed,
Yup the code will work for bulk data, there is a little bit modification with the recordType is needed, See the updated code below
Please have a look on this , I hope this will help.
I changed the cmemberUpdate list to the following but it seems to compare each campaign member to one event although mutiple events have been added..
List<campaignMember> cMemberToUpdate = [SELECT id FROM campaignMember WHERE status = 'Attended' and contact.id = :WhatID
and campaignId IN :campaignId];