+ Start a Discussion
vutukuru balajivutukuru balaji 

how to change owner of record using trigger when we are deactivating the current owner ?

hi i have a task when we deactivating a user,the ownership of all the records owned by this user has to changed to his manager by using trigger.can any body please help for the code that need to be write for the trigger
Ankit AroraAnkit Arora
Here I hope we are not talking about a single object. There must be multiple records from multiple objects which are owned by current user. So either can use SOSL or you've to write SOQL on all those object in same class. This is all done via trigger on USER.

Once you've the results, you've to loop over it and change the owner of it. Or if there are possibilities of having records in bulk then you can use batch as well.
vutukuru balajivutukuru balaji
suppose user had records in  account only then tell me the trigger code to change owner name.