Search code examples
salesforce

How to override default welcome email for newly created users (not only Community users)?


I have a usecase where i need to customize a welcome email for a newly created User which has a specific Category. I want to find a way to override or disable the default welcome email from Salesforce to users so that only my customized welcome email is sent to them. But there is no way to override or disable the default welcome email. The default welcome email as below: enter image description here

I tried to create a Flow to send my customzied email to users but haven't found a way to disable/override default welcome email from Salesforce.


Solution

  • It's been few years but I think you can suppress sending the email by inserting the user with "dml options"

    User u = new User(...);
    Database.DMLOptions dlo = new Database.DMLOptions();
    dlo.EmailHeader.triggerUserEmail = false;
    database.insert(u, dlo);
    

    If you're inserting them via UI it should match the checkbox at the bottom of the page, "send email and generate user password automatically". If you insert them via API - SOAP API and REST API have headers that correspond to these options.

    And once you're ready to send it... probably things like System.resetPasswordWithEmailTemplate(userId, sendUserEmail, emailTemplateName)?