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
Delinda TinkeyDelinda Tinkey 

trigger to update account when contact field is updated

Hello, I'm wondering if anyone can help with what I believe is a straight-forward trigger.

We have a contact field called Last_Campaign_Response__c, which is a text field. We have the same field on the account. I'd like the field on the account to be populated with the value from the related contact when:

- the contact is edited and that field's value is updated
- the contact is created (including from a lead convert) and that field is not empty

Thanks!
AmulAmul

Hi Delinda Tinkey,

I have one question here. In sfdc one Account can have multiple Contact. like "ABCL LTd" account have "John Mathwe" and "Bob Buzzard" as contact record associated with Account.so which contact information do you populate on "Last_Campaign_Response__c field of Account.?









 

Delinda TinkeyDelinda Tinkey
I'd like the field to always be populated with the latest campaign response from any contact (which I will take care of populating on the contact level). Would you recommend adding a corresponding "Date" field to the response in order to accomplish this, or simply allowing the Account level field to update whenever the contact level is updated?

My ultimate goal is to pass this value to an opportunity if/when one is created on the account.