function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
venkatsforcevenkatsforce 

InActive the PortalUser using apex class

Hi All

 

              Is this possible to In-Active(deactivate) the CustomerPortaluser using apex class?

 

Thanks

------------

Venkatsforce

Vinita_SFDCVinita_SFDC

Hello,

Just make a check on IsActive and IsPortal user. Ex:

for(User u : [Select u.Id, u.IsActive, u.IsPortalEnabled from User u where u.name = 'abc']){
  if(u.IsActive || u.IsPortalEnabled ){
    u.IsActive = false;
    u.IsPortalEnabled = false;

}

}

Hope it hepls!

venkatsforcevenkatsforce

Am using portaluser accesstoken to run my services but i got error like this...  "Update failed. First exception on row 0 with id 00590000001g7hXAAQ; first error: FIELD_INTEGRITY_EXCEPTION, Cannot de-activate self: Active: [IsActive]"