When i create new user through salesforce UI i dont want the password notification to be sent to the User .Is this possible ?I know one solution is to uncheck the generate Email Notification and new password email check box .Is it possible through trigger before insert in case the admin forgets to uncheck that ?
-
Might want to look at DmlOptions emailHeader.sendUserEmail = false along with the setOptions method of the User in a trigger (not sure if it would be before or after insert).– Peter KnolleJan 9, 2013 at 11:13
-
Hard luck tried with before insert and also after insert :(– Mohith ShrivastavaJan 9, 2013 at 12:01
-
Have you tried contacting support and just asking if it is a feature you can have turned off globally? If you don't ever want that email to go out, this might be an option.– pchittumJan 9, 2013 at 13:14
-
Thanks for this suggestion.My problem is profile specific .A super User profile clone of admin when he creates users no email suppose to go .For data load of user we had salesforce to turn off for us globally .Now we have asked them to enable .Also there are administrative permissions to stop the profile users to send email but this stops even batch finish emails that we have custom coded after every batch .any ways thanks for your answer– Mohith ShrivastavaJan 9, 2013 at 13:17
3 Answers
Database.DMLOptions dmlo = new Database.DMLOptions();
dmlo.EmailHeader.triggerUserEmail = false;
// give true if you want to send email notification.
Database.insert(user, dmlo);
-
2Please qualify your code example with an explanation of the purpose and how it fits the solution– BartleyApr 3, 2014 at 7:52
You have two options.
While creating the new user, dont put the correct email address. You can either use a dummy email address or maybe the admin's email address. This way emails will not go to the actual users. However there is downside to it. The downside is that you eventually have to change the the dummy address to the correct email address. And when you do that Salesforce send an email to the user asking him to confirm the change. If your users dont mind receiving this email, VOILA.
Create a VF page that should look just like the new user page without the checkbox. And then the code behind insert a new user object using the data obtained from the VF page.
Also please let me know if any of these two solutions work. So that others may also benefit from it.
-
Thanks for the reply.The pagelayout of user record is not completely under our control and i fear we cannot replace it . Jan 10, 2013 at 3:01
-
which field we have to set false while inseting user by dataloader. I was able to do so, but not sure, which field it was.– AnkuliJun 26, 2017 at 19:30
You can achieve this by using Data Loader.User Insert operation using Data Loader to Insert the users with Avoiding the password notification to the inserted users.while inserting please make sure that the mandatory fields are filled or not.
Thanks, Kiran