You need to sign in to do that
Don't have an account?

Unexpected behaviour of trigger on User Object
I have a contact which has a partner user. I am disabling the partner user from contact detail page by selecting "Disable partner user" option from "Work with Portal Button" dropdown.
I have a trigger on User object which fires on after update event.
trigger TR_User on User (after update) {
system.debug('########'+trigger.new[0].IsActive + '-' + trigger.old[0].IsActive);
}
In this trigger I am checking the IsActive field value of user object. But both Trigger.New[0].IsActive and Trigger.Old[0].IsActive returns same value i.e true. While I was expecting it to become false as User is disassociated from the contact in this process.
I am not sure whether it is a bug in the Salesforce or I am missing something...
Please Suggest.
Thanks,
Devendra Natani
The isActive field on the user can take up to 10 seconds to register the change to false when the portal user is deactivated from the contact. The isportalenabled field on the user shows the correct change of state during this event, and can be used as the flag for a trigger.
See: (after update trigger on user)
10:26:21.168|USER_DEBUG|[6]|DEBUG|
##########Trigger.new: User:{IsPortalEnabled=false, IsActive=true}
##########Trigger.old:User:{ IsPortalEnabled=true, IsActive=true }
All Answers
Hi Friend,
I have couple of queries by seeing our post.
1) have you tried to login with the disabled user using the portal link (URL)?
2) have you checked isActive checkbox is unchecked?
3) On which criteria are you determining the contact is associated to particular diabled account?
Thanks,
:smileyvery-happy:
The isActive field on the user can take up to 10 seconds to register the change to false when the portal user is deactivated from the contact. The isportalenabled field on the user shows the correct change of state during this event, and can be used as the flag for a trigger.
See: (after update trigger on user)
10:26:21.168|USER_DEBUG|[6]|DEBUG|
##########Trigger.new: User:{IsPortalEnabled=false, IsActive=true}
##########Trigger.old:User:{ IsPortalEnabled=true, IsActive=true }
Thanks KyleKyle,
had the same problem and thanks to your suggestion it started working!!
Even if you disable the partner contact the user is still active as a non-partner user in salesforce. IsActive flag is related to salesforce user and not its partner contact user.