Category: triggers
-
Getting name of previous owner of account
1) Create a lookup field “Previous Owner” in Account as LookUp(User) 2) Create a trigger like this: trigger OnAccountOwnerChanged on Account (before update) { for( Account a : Trigger.new ) { Account AcctBeforeUpdate = Trigger.oldMap.get( a.Id ); if( AcctBeforeUpdate.OwnerId != a.OwnerId && ((String) a.OwnerId).startsWith( ‘005’ ) ) a.Previous_Owner__c = AcctBeforeUpdate.OwnerId; } } 3) Use the…