+ Start a Discussion
lavanya gottumukkalalavanya gottumukkala 

Is it possible to reactivate a deactivated user through apex code

Hi All,

While updating the user record of the deactivated user by making IsActive as 'true' through apex code we are getting below error.
Update failed. First exception on row 0 with id 005F0000005sY9qIAE; first error: INVALID_CROSS_REFERENCE_KEY, Cannot activate a disabled portal user: [IsActive]

Is it possoble through code or not?
Can any one help me on this matter?

Thanks in advance
Amit Chaudhary 8Amit Chaudhary 8
Please check below post. I hope that will help you
https://help.salesforce.com/apex/HTViewHelpDoc?id=customer_portal_disable_users.htm&language=en (https://help.salesforce.com/apex/HTViewHelpDoc?id=customer_portal_disable_users.htm&language=en)

Please let us know if this will help you.

Amit Chaudhary
Mudasir WaniMudasir Wani
I tried from developer console and it works.
User usr = [SELECT AboutMe,ContactId,Email,Id,IsActive,Name FROM User WHERE IsActive = false limit 1];
usr.IsActive = true;
update usr;