You need to sign in to do that
Don't have an account?
Trigger to update Standard Object when an unrelated objects field is changed.
I have a field(WAM__c) on the Account object that is a lookup to user. It is set automatically by code from a custom object called Territory_State__c. There is a checkbox that allows users to bypass the code and manually set the WAM. My issues is that all accounts are set by which state is on the billing address, which then grabs WAM__c from Territory_State__c. What I am having trouble with, is that if for some reason say the WAM__c on Territory_State__c for the state of TX is changed I need it to update all Accounts that have that state.
Account.WAM__c set by Territory_State__c.Website_AM__c they are not related.
IF Territory_State__c.Website_AM__c is changed I need it to change on Account.WAM__c.
Thanks in advance for any help.
William Shrewsbury
Try the following
Write a trigger on Territory_State__c,
In the trigger, get all account by state and put it in a map<String, List<Account>> accountsByState
check for field Website_AM__c change, (compare with oldMap)
and if changed, update all accounts WAM__c by getting the List of account by state (eg: accountsByState.get('TX');)