You need to sign in to do that
Don't have an account?
ai501.3910110299805757E12
trigger to update lookup fields in 2 object lookup fields
trigger to update lookup fields in 2 object lookup fields My requirement is :
ex:- accounts and contacts objects has common field city if i update city field in accounts then it must update in contacts also.
i am having 2 lookup fields in 2 different objects which is a common field named "city"
If i update a city name using lookup for example california is changed to *washington* the change must update all records which have california must be changed to washington the changes must reflect in 2 objects same time.
ex:- accounts and contacts objects has common field city if i update city field in accounts then it must update in contacts also.
i am having 2 lookup fields in 2 different objects which is a common field named "city"
If i update a city name using lookup for example california is changed to *washington* the change must update all records which have california must be changed to washington the changes must reflect in 2 objects same time.
I'm having a hard time following what you are saying, but it sounds like you have an Account and a Contact that look up to a City object. When you change the city name you want it to reflect in both objects? You actually shouldn't need any trigger for this case if they are looking up to the same object. It would be reflected automatically.
If instead you mean that City is a field and not a lookup on Account/Contact, but they have a lookup to each other then you approach it a little differently. A trigger could query for the associated other record and you can copy over the data from what you queried. You could alternatively have one of those fields be a formula field and have it simply be read only and grab the value contained in the other's field.
You need to create two trigger on both objects with a help class to control the recursion condition. One on parent object and one for child object.