4

I can't figure out how to set IsPortalEnabled to true, once it has been set to false. Not a critical issue, just trying to increase my knowledge and understanding of the platform.

I was playing around on my dev org and ran:

list<user> lst = new list<user>();
for(user u :[SELECT id, name , IsPortalEnabled, isActive FROM User where IsPortalEnabled=true]){
   u.Isportalenabled=false; 
   lst.add(u);
}
update lst;

which disabled my portal user and set him to active, trying to reactivate the user in through the gui I got "Error: Cannot activate a disabled portal user" which is understandable.

Trying to reverse my actions, I ran:

list<user> lst = new list<user>();

for(user u :[SELECT id, name , IsPortalEnabled, isActive FROM User where id = '005d0000001DXMx']){
    u.Isportalenabled=true;
    lst.add(u);
}
update lst;

which gave an dml exception

EXCEPTION: System.DmlException: Update failed. First exception on row 0 with id 005d0000001DXMxAAO; first error: INVALID_CROSS_REFERENCE_KEY, Cannot enable a disabled portal user: [IsPortalEnabled] STACKTRACE: AnonymousBlock: line 7, column 1

Trying to re-enable the portal user through the button on the contact detail page, just ended up in creating a new user.

Anyone who can shed some light on this, is it totally not possible to reverse setting IsPortalEnabled to false ?

6

I'm pretty sure that you cannot re-enable that exact user record once it is disabled (which is what the error message states...sort of). Take a look at http://login.salesforce.com/help/doc/en/customer_portal_disable_users.htm.

  • ah darn, I didn't find that when looking in the documentation. – Samuel De Rycke Aug 9 '12 at 9:44

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.