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
cheminchemin 

Notify password to new customer portal user from Apex code

Hi,

 

I'm writing apex code which automates creation of a customer portal user.

First I create a new contact. Then I create a new user linked to that contact, with all required attributes to access the customer portal. It all works well except that I can't get the new password notification sent to the new user.

 

In other words, I can't find a way to "select" the "Generate new password and notify user immediately" option from apex.

 

Any hint would be highly appreciated!!!

 

Thanks,

 

pblzpblz

I'm looking for essentially the same thing!

 

OR any such workaround.

 

Have tried in APEX to create Account and Contact linked to said account and ticked the IsPortalSelfRegistered tickbox and created User Record linked to said contact but no luck.

 

Have tried to mimic HTTP Post to Customer Portal URL "new user signup form" and again no luck.

 

I get standard System.CalloutException: Callout from triggers are currently not supported error.

 

Really need some sort of solution here. 

 

You can 'SetPassword()' and 'resetPassword()' via the API but not via APEX??? seems a little odd.

 

I know there is a sites class coming with a createPortal user method but that's not general release yet and I need something now.

 

Anywho anyone with any insight whatsoever let me know I'll keep plugging away, with a few other ideas.

Message Edited by pblz on 03-22-2009 10:40 PM
saharisahari
Database.DMLOptions dlo = new Database.DMLOptions();

dlo.EmailHeader.triggerUserEmail = true;

This code might help when you create users via apex.

 

Is there any setting on Data Loader for this? I am trying to generate password for all the users I insert using Data Loader.

Let me know if there is any work around for this.

Greg-oGreg-o

That is only setting the options, not applying it to your object.  You will need to use the setoptions method.

 

Database.DMLOptions dlo = newDatabase.DMLOptions();

dlo.EmailHeader.triggerUserEmail= true;

u.setOptions(dlo);

 

where u is a reference to my user object.