+ Start a Discussion
Kel HillKel Hill 

Update the corresponding custom field on two other objects if it is updated on any of the three objects it exists on

We have a custom field (number type) on Leads, Opportunities and Accounts. We would like the field to update on all three records regardless of which object the user updates it on. Is this possible? (I am not a programmer and have never used triggers before; can I get help with how to use them, if they are the answer?) Thanks.
Best Answer chosen by Kel Hill
Ajay Ghuge 6Ajay Ghuge 6
Hi Kel,

You can achieve this through trigger but you need to take extreme care while writing this as it will cause a recursion of events.

For example : Lead field update -> Account & Opportunity fields update.
                       Account field update -> Lead & Opportunity fields update ,
                       Opportunity field update -> Account & Lead fields update.

This will cause a unended cycle of events so use trigger.old and trigger.new to avoid the recursion.

Regards,
Ajay
 

All Answers

Ajay Ghuge 6Ajay Ghuge 6
Hi Kel,

You can achieve this through trigger but you need to take extreme care while writing this as it will cause a recursion of events.

For example : Lead field update -> Account & Opportunity fields update.
                       Account field update -> Lead & Opportunity fields update ,
                       Opportunity field update -> Account & Lead fields update.

This will cause a unended cycle of events so use trigger.old and trigger.new to avoid the recursion.

Regards,
Ajay
 
This was selected as the best answer
Kel HillKel Hill
Thanks, Ajay. Is there any other way than triggers to accomplish this?
Ajay Ghuge 6Ajay Ghuge 6
Hi Kel,

I think it depends upon how you are matching records. If its a complex logic then you will have to write trigger for this. 

Regards,
Ajay
Kel HillKel Hill
What is the best way to accomplish this logic?

SCENARIO ONE
User updates AuthForms number field on an Account
IF that Account contains any Leads or Opportunities, populate the AuthForms number field on those Leads and Opportunities with the same number that has been entered by the user on the Account

SCENARIO TWO
User updates AuthForms number field on a Lead
IF that Lead is attached to an Account, populate the AuthForms number field on that Account with the same number that has been entered by the user on the Lead, and if that Account has any Opportunities attached to it, populate the AuthForms number field on those Opportunities with the same number that has been entered by the user on the Lead.

SCENARIO THREE
User updates AuthForms number field on Opportunity
IF that Opportunity is attached to an Account, populate the AuthForms number field on that Account with the same number that has been entered by the user on the Opportunity, and if the Account has any Leads attached to it, populate the AuthForms number field on those Leads with the same number that has been entered by the user on the Opportunity.
 
Ajay Ghuge 6Ajay Ghuge 6
All of the scenarios possible through trigger only. You need to write triggers on after insert, after update triggers on each object.
Ajay Ghuge 6Ajay Ghuge 6
Kill you can close this thread so that it appears in a solved issue.
Kel HillKel Hill
Are there any examples of code for anything similar?