-
-
Notifications
You must be signed in to change notification settings - Fork 54
Specify the Running User via Named Credentials
Home > Getting Started > Examples > Specify the Running User via Named Credentials
When any action is taken in Salesforce, the currently logged in user is known as the running user (also known as the context user), for those actions. The running user is whose name gets stamped as the "Last Modified By" when records are created or updated. Access to records and what the running user can do is determined by their assigned permissions (e.g. profile, permission sets) and any sharing rules.
Since Mass Action Scheduler is often used to schedule actions to happen automatically when no physical user is logged in to Salesforce to be the running user, then you have a couple options to specify who that running user is.
By default, the user who last activates a Mass Action Configuration record, or who manually runs it, is the running user. You also have the option to specify the running user by selecting a Named Credential on the Details step when configuring the record.
This page helps you create a Named Credential to specify the running user if you want that running user to be someone else other than the user who creates and activates the Mass Action Configuration record. Each Mass Action Configuration record can have a different Named Credential specified, or no Named Credential specified.
- Create Connected App
- Create Auth. Provider
- Create Named Credential
- Assign Named Credential to Mass Action Configuration Record
Note that steps 1, 2, and 3 can be done automatically for you by navigating in app to the Mass Action Auth. Setup page.
NOTICE: Steps 1, 2, and 3 can be done automatically for you by navigating in app to the Mass Action Auth. Setup page.
- In Setup, type
App Manager
in the quick find - Click
New Connected App
button then fill out the form:- Connected App Name =
Mass Action
(or preferred name) - API Name =
Mass_Action
- Contact Email =
<your email>
- Enable OAuth Settings =
<checked>
- Callback URL =
https://localhost.com
(we will change this after creating an auth provider) - Selected OAuth Scopes =
Full access
andPerform requests on your behalf at any time
- Connected App Name =
- Click
Save
button then wait 10 minutes (otherwise may get errors about setup not ready when moving on to next steps) - On the detail page, note the Consumer Key and Consumer Secret values (we will use these in next steps)
NOTICE: Steps 1, 2, and 3 can be done automatically for you by navigating in app to the Mass Action Auth. Setup page.
- In Setup, type
Auth. Provider
in the quick find - Click
New
button then fill out form:- Provider Type =
Salesforce
- Name =
Mass Action
(or preferred name) - URL Suffix =
Mass_Action
- Consumer Key =
<enter value from connected app>
- Consumer Secret =
<enter value from connected app>
- Provider Type =
- Click
Save
button - On the detail page, copy the
Callback URL
then go back to your connected app and replacehttps://localhost.com
with this new Callback URL
NOTICE: Steps 1, 2, and 3 can be done automatically for you by navigating in app to the Mass Action Auth. Setup page.
- In Setup, type
Named Credential
in the quick find - Click
New Named Credential
button then fill out form:- Label =
Mass Action
(or preferred name) - Name =
Mass_Action
- URL = depends on the version of the package installed
- For versions 2.3 or later:
https://<MyDomain>.my.salesforce.com
- Only the My Domain URL without any path suffix.
- The API path suffix is determined at runtime to allow use of SOAP or REST APIs.
- For versions 2.2 or earlier:
https://<MyDomain>.my.salesforce.com/services/data/v46.0
- The My Domain URL with the versioned REST API path suffix.
- In Lightning Experience your URL may look like
https://<MyDomain>.lightning.force.com
. Make note that the URL for the Named Credential does not use.lightning.force.com
but rather.my.salesforce.com
. - For sandboxes, the URL must include the instance (e.g. CS23 or CS58) like
https://<MyDomain>.<instance>.my.salesforce.com
. To know your instance name navigate in Setup toCompany Information
and look for the field labeledInstance
. - Examples:
- Production URL:
https://my-production-domain.my.salesforce.com
- Sandbox URL:
https://my-sandbox-domain.cs23.my.salesforce.com
- Production URL:
- For versions 2.3 or later:
- Identity Type =
Named Principal
- Authentication Protocol =
OAuth 2.0
- Authentication Provider =
<choose the auth. provider you created earlier>
- Scope =
full refresh_token
- Start Authentication Flow on Save =
<checked>
- Generate Authorization Header =
<checked>
- Allow Merge Fields in HTTP Header =
<checked>
- Allow Merge Fields in HTTP Body =
<checked>
- Label =
- Click
Save
button, a login page will open - Follow on-screen instructions to login as the
running user
you want to assign to thisNamed Credential
(I suggest an admin user)
- Navigate to a Mass Action Configuration record and on the Details step, choose your Named Credential, and click Save.
The next time the job runs then the Named Credential will be used as the running user when the target actions perform their updates on the source records.
Home | About | Getting Started | Sponsor | Copyright © 2017-2023 Douglas C. Ayers. Terms of use.