Reputation: 72
In Salesforce, when I create a user via their REST API, no activation email is sent. There's also no ability to specify a password when the new user is created, which means the user cannot login. This also means the user can't verify their email at the same time as activating.
Is there a way to ensure an activation email gets sent to new SFDC users when they're created via API?
The Salesforce developer documentation is pretty lacking in this regard, so I'm not sure if I'm overlooking something.
The only two "solutions" I've come across are:
Tried adding a new user via API but no activation email was sent. Was expecting one to be sent.
Upvotes: 1
Views: 1932
Reputation: 19612
Uh, good question!
"Normal" Apex has DmlOptions (triggerUserEmail) for that or System.resetPassword('user id goes here')
call.
SOAP API has corresponding headers: https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_header_emailheader.htm
But looks like REST API is lacking and has only Case/Lead Assignment Rule header.
Would it be an option to try the SOAP route? Disappointing but you'd "just" have to craft the right XML, the session id (a.k.a. access_token, the "Authorization: Bearer ..." value) is reusable across APIs
Would it be an option to combine the REST calls into 1 "all or nothing" operation. It's called composite requests. Insert, then use the referenceId
to call https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_sobject_user_password_delete.htm ? I've used composites in the past, not for user stuff but they're pretty cool: https://salesforce.stackexchange.com/a/274696/799 (for more complex integrations I'd still prefer to expose an Apex webservice for all-or-nothing atomic operation rather than trusting the calling system to do it right... but hey, it's there, it's neat, it's "just" a little more involved JSON to write)
Or you could write something in SF itself
Upvotes: 2