Reply
Visitor
David Jordan saaspoint
Posts: 2
0

how to disable a customer portal contact/user within APEX?

Is it possible to disable customer portal users via APEX?

 

I have a trigger which deactivates users via a trigger on a contact checkbox field called "Provision extranet", but the contact record cannot be deleted until the portal user is disabled. I would like to deactivate and disable the user in one operation.

Regular Contributor
Mayank_Joshi
Posts: 96
0

Re: how to disable a customer portal contact/user within APEX?

Hi,

 

Could you pass me trigger , so that i have better understanding.

 

 

Mayank Joshi
BirlaSoft Ltd| Noida | INDIA
There are two ways of writing a code, the hard way and the best way, Of-course the hard way is the easy way&best way is always hard way.
Visitor
David Jordan saaspoint
Posts: 2
0

Re: how to disable a customer portal contact/user within APEX?

Thanks for the reply, but I figured it out.
I just needed to set the IsPortalEnabled to false. Previously, I was just setting IsActive to false.

for(User u : [Select u.Id, u.IsActive, u.IsPortalEnabled from User u where u.ContactId in :cIds]){
  if(u.IsActive || u.IsPortalEnabled ){
    u.IsActive = false;
    u.IsPortalEnabled = false;
  usersToUpdate.add(u);
  }
}