You need to sign in to do that
Don't have an account?
Virtuoso123
Generate a Self Service user's Password automatically
I'm fairly new to Apex Development. Our organization has a requirement to insert Contacts into the system and on insert or on update to the contacts, a Predefined password needs to be set for the Contact to be able to login to Self Service Portal. I was wondering if this is possible at all?
You can use
1)FIrst you hae to create a portal user for this contact, just create a user with insert statement, only thing is set contactid of user to contact for you want to create user, and profileid should be your service portal profile id .
Then you can use
system.setPassword(userID , PasswordString) method
Sets the password for the specified user.When the user logs in with this password,ID userID VoidString passwordsetPasswordthey are not prompted to create a newpassword.
Let me know if any issues in it.
Thanks Shashikant.
I tried to insert a portal user using insert statement, but got an error:
DML not allowed on SelfServiceUser
Could u guide me please?
Are you doing it in constructor? Could you please share the code?
I'm doing it with a trigger:
Map<id,SelfServiceUser> ssu = new Map<id,SelfServiceUser>([Select id, name,contactid, username from SelfServiceUser]);
for(Contact c : trigger.new){
if(ssu.containsKey(c.id)){
ssu.get(c.id).username = c.ID__c;
ssu.get(c.id).name = c.name;
update updateSSU
}else{
SelfServiceUser s = new SelfServiceUser();
s.username = c.ID__c;
insert insertSSU
}
What is your profile when you invoke this trigger. Is it a portal user?
System Admin
Ok i just discovered that you can not update or create SelfServiceUser in Apex.
Here is your solution if you want it.
http://boards.developerforce.com/t5/Apex-Code-Development/Create-Enable-new-SelfServiceUser-when-contact-is-created/td-p/120070