I thought I could handle this in a User before update trigger, but it seems I'm wrong - when a user is deactivated, the before trigger does run, but the transaction is stopped entirely, the after trigger is not fired, and anything done in the before trigger is rolled back.

I tried calling a queueable class in the before trigger and that does not get queued up either.

Anyone found a clever way to do anything at all in Apex when a user who is receiving leads is attempted to be deactivated?

trigger UserTrigger on User (before update, after update) {
            for(User U : trigger.new){  system.debug('>>>>>>>>>>> Before is active = '+U.IsActive);
                User OldU = trigger.oldMap.get(U.ID);

                if(!U.IsActive && OldU.isActive){
                    UserHandler.UpdateUser Job = new UserHandler.UpdateUser();
                        Job.Users = trigger.new;
                    system.debug('>>>>>>>>>>> No?');
        catch(Exception e){
            system.debug('>>>>>>>>>>> Exception = '+e);

1 Answer 1


No, there's nothing you can do. The "System Validation" step in Triggers and Order of Execution fires before your triggers get a chance to, so you can't do anything about it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .