1

I don't want to trigger welcome to salesforce email on user creations. I have achieved that by inserting users using workbench and by setting Trigger User Emails to false. Now I want to send the welcome email only after I'm done with some setup for each user. How can I achieve this? I'm aware of system methods like System.resetPassword(userId, sendUserEmail) & setPassword(userId, password) but using them resets and sets the password respectively. I want to send the Welcome email without going to each user record and check 'Generate new password and notify user immediately'.

  • 1
    Create a time based workflow with an email action – Boris Bachovski Mar 21 '16 at 2:23
  • @BorisBachovski How can I put 'Verify Account' on an email template? Maybe my question is not clear, I want to send welcome emails later, the time gap could be hours, days etc. My requirement is to send the welcome email later. – Jarvis Mar 21 '16 at 2:40
  • Are these community users? – Boris Bachovski Mar 21 '16 at 2:41
  • These users are standard salesforce users. – Jarvis Mar 21 '16 at 3:06
  • This is a good question. The best I've been able to do is to use process builder and an invocable method to reset the user's password when i activate the user via process builder, but it doesnt send the 'welcome' email. I get the feeling that isnt possible. – gorav Feb 1 '17 at 2:40
0

I'm using process builder and an 'activation date' custom field to trigger user activation. Like you, I want to send the 'welcome' email to the user, with the nice formatting as below:

welcome email

So far, I have not found any way to trigger this welcome email.

The only thing i've been able to do is trigger the password reset email, which is much less compelling.

enter image description here

I'm doing this using an invocable method, with the following code. I initially thought I could do this just by activating user w/ EmailHeader.TriggerUserEmail = TRUE, but that did not do anything. I had to use the System.resetPassword method (in a loop!) to make it work.

I dont think process builder would put multiple users in the same set of IDs but PB bulkification is unclear so thought best to be safer.

Here is the code I'm using.

public class ActivateUsersWithNotification
{
    @InvocableMethod
    public static void ActivateUsers(List<Id> UserIds)
    {
            Database.DMLOptions dmo = new Database.DMLOptions(); // this didnt make any difference
            dmo.EmailHeader.triggerUserEmail = true;
            list<User> Users= new List<User>([select id from user where user.id in :UserIds]);
            for (User u : Users) {
            u.setOptions(dmo);  // this didnt make any difference, could remove it
            u.IsActive = TRUE;       
            }        
            database.update(Users,dmo);
            for (User u : Users) {
            System.resetPassword(u.Id,True);
            }

   }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.