0

I try to set up a trigger that modifies the email adress on the User object once I hit the button "Disable Customer Account" on Account. I have seen the discussions where you should use "IsPortalEnabled" instead of "IsActive" on the User object to determine if the user object got disabled. So, generally it should function (see Run a trigger when disabling a customer user)

However, in my case the trigger does not even get fired:

trigger User on User (before insert, before update, after insert, after update) {

  SM018_UserTriggerHandler handler = new SM018_UserTriggerHandler();



  if((Trigger.isUpdate) && (Trigger.isBefore)){
        System.debug(logginglevel.debug, 'Update Before');
    }

    if((Trigger.isInsert) && (Trigger.isBefore)){
        System.debug(logginglevel.debug, 'Insert Before');
    } 

    if((Trigger.isUpdate) && (Trigger.isAfter)){
        System.debug(logginglevel.debug, 'Update After');
    }

    if((Trigger.isInsert) && (Trigger.isAfter)){
        System.debug(logginglevel.debug, 'Insert After');
    }

}

I do not get any entry in the debug log - what am I missing here? If I modify the User directly and not via the button "Disable Customer Account", the trigger functions.

Should I set up a trigger on Account despite the discussions that the trigger should function on the User object? And is the correct field for the trigger "IsCustomerPortal" then?

1

You should set up a trigger on Account instead of User as Any User field has not changed.

And when you are directly modifying User then it will showing logs because you are making changes on User.

I tried on Account trigger and it worked for me.

| improve this answer | |
  • 1
    The User fields do change when you use the "Disable Customer Account", for example the IsActive is set to false, the Username is changed and connections to other objects are deleted. However, for whatever reason there is no trigger executed. I also worked my way around with setting up a trigger on Account and used "IsCustomerPortal" as an indicator. I found though that you cannot really test the hitting of the button "Disable Customer Account" which could be an issue regarding code coverage. – user40501 Feb 28 at 8:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.