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
TigerPowerTigerPower 

How to enable self service portal automatically?

Hi there,

is it possible to automatically enable self-service portal for a contact? This could be done manually by clicking "enable self-service portal" standard button at the contact record. Could this be done automatically with an apex trigger?

 

 

hisrinuhisrinu

I could see a SelfServiceUser object where in I can see creatable/updatable properties for this object.

 

I think you can automatically create self service user whenever you create a contact.

 

Here is the pseudo code and it might work for you.

 

 

 

for(contact c : trigger.New){
SelfServiceUser s = new SelfServiceUser();
s.ContactId = c.id;
s.Email = c.email;
s.FirstName = c.firstname;
s.IsActive = true;
s.LastName = c.LastName;
s.Username = c.email+'.ss';
insert s;

 

 

 

 

Pradeep_NavatarPradeep_Navatar

I have tried the trigger to make contact as a self service user or super user. It seems that DML operations are not allowed for self service user :

 

     trigger SelfUsercontrgger on Contact (after insert,before update)

     {

     Contact con  = trigger.new[0];

     Id contactid = con.id;

     SelfServiceUser u = new SelfServiceUser(contactId=contactid, username=con.Email, firstname=con.FirstName,

     lastname=con.LastName, email=con.Email,languagelocalekey='en_US', localesidkey='en_US'

     timezonesidkey='America/Los_Angeles');

     insert u; //  DML operation not allowed here.

     }

 

Hope this helps.

 

TigerPowerTigerPower

Thank you both for the answers! So basically the idea of the apex code is pretty simple, but at the moment INSERT is not supported by SF? And there is no other way to achieve this...

skjaiswalskjaiswal

Hi there,

 

I really need to enable self service portal automatically.

 

Is there any way ? Or, simply it cannot be achieved ?

 

Please comment here..