Salesforce Named Credentials

Purpose:
This Named Credential allows Salesforce to securely authenticate with itself (Salesforce-to-Salesforce) to make automated configuration changes—such as creating or updating fields – without manual intervention. It is required for the ServiceNow integration to programmatically manage Salesforce metadata.

Used When:

  • Supporting the two-way integration with ServiceNow, where we use a Salesforce object as the ServiceNow Record and dynamically create fields depending on table settings. This ensures that all data is properly synchronized in reports and other integrations.

Why Needed:
Without this Named Credential, every change would require manual updates in Salesforce. Using it ensures that field creation, updates, and metadata synchronization happen automatically, keeping Salesforce and ServiceNow fully in sync.

 

How to Configure a Salesforce Named Credential for Salesforce-to-Salesforce API Calls

Step 1: Create an External Client App
    • Navigate to Setup → App Manager.
    • Click New External Client App.
    • Fill in all required fields: External Client App Name, Contact Email, and Distribution State (you can leave the default).
    • Make sure to enable OAuth.
    • Set the Callback URL to:
      https://example.com/ (this will be updated later).
    • Under Selected OAuth Scopes, choose:
  • Full Access (full)
  • Perform requests at any time (refresh_token, offline_access) 
  • Save the app.
  • After saving:
    • Click Settings
    • Scroll to OAuth Settings
    • Open Consumer Key and Consumer Secret
    • Copy both values (you’ll need them in the next steps)

⚠️ You will return to this app in Step 3 to update the Callback URL.

 

Step 2: Create an Authentication Provider
  • Go to Setup → Auth. Providers.
  • Click New.
  • Set Provider Type to Salesforce.
  • Fill in the fields:
    • Name:  Enter an appropriate name
    • URL Suffix: Automatically fill in from the Name field
    • Consumer Key: from Step 1
    • Consumer Secret: from Step 1
    • Authorize Endpoint URL:
      https://yourInstance.my.salesforce.com/services/oauth2/authorize
    • Token Endpoint URL:
      https://yourInstance.my.salesforce.com/services/oauth2/token
    • Default Scopes:
      refresh_token offline_access full
  • Leave all other fields as default unless required.
  • Click Save.

⚠️ After saving, Salesforce will generate a Callback URL.
Copy this URL — it is required for the next step.

 

Step 3: Update the External Client App (Callback URL)
  • Return to the External Client App created in Step 1.
  • Click Edit Settings.
  • Replace the existing Callback URL with the one copied from the Auth. Provider (Step 2).
  • Save the changes.

 

Step 4: Create the Named Credential
  • Go to Setup → Named Credentials.
  • Click New Legacy.
  • Complete the fields:
    • Label: Choose a meaningful name
    • Name: Auto-filled or custom
    • URL: Your Salesforce instance URL
      (e.g., https://yourInstance.my.salesforce.com)
    • Identity Type: Named Principal
    • Authentication Protocol: OAuth 2.0
    • Authentication Provider: Select the provider created in Step 2
    • Scope: refresh_token offline_access full
    • Start Authentication Flow on Save: Checked
    • Generate Authorization Header: Checked
    • Allow Merge Fields in HTTP Header: Checked
    • Allow Merge Fields in HTTP Body: Checked

Click Save and complete the authentication flow.

Ready to simplify your Salesforce integrations?

    Peeklogic AI Orchestrator