function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Auo-Update the Account Owner field if Account Owner becomes Inactive

I would like a way to update the account owner if the account owner becomes inactive.


Basically for example:  Joe owns an account and Joe becomes inactive, somehow I would like the account owner to update to an active user "Active User" user id '00530000000eUnrs'. So any account that has a inactive owner would default to this same user.


Is there a easy solution for this?


Thanks for any help there


Since you can't put a trigger on User to udpate the accounts after you have innactivated the user because of a mixed DML exception, you need to make a util method that is @future that will take in the list of user Ids that are innactivated,find their accounts, and update them to the user you want.  This will run the account moving in a separate thread to prevent the mixed DML exception.


I don't recommend hard-coding the user id in there and instead using a custom setting so that any testing around this will pass in other environments than the one in which you are developing (as user ids are global unique)