Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

ServiceNow to Salesforce Integration using REST API and OAuth 2.0

yashkamde
Giga Sage

As a ServiceNow developer, I've always believed the platform's real power isn't just managing what happens inside it, it's how cleanly it can talk to everything outside it. So instead of building a one-off create a record and take a screenshot demo, I tried something closer to how real integrations actually get used: two independently triggered, real-time syncs from ServiceNow into Salesforce, both running on the same underlying architecture.

SN to Salesforce Img.png

Introduction

What if creating a user in ServiceNow could automatically create the corresponding Account in Salesforce, and creating an Incident could automatically create a Case in Salesforce without anyone manually entering the same information twice?

This is where integration between ServiceNow and Salesforce becomes useful. Here, I will walk through a practical ServiceNow → Salesforce integration.

 

Overview

 

ItemValue
Auth FlowOAuth 2.0 Client Credentials
Salesforce Object AccessedCase
DirectionServiceNow -> Salesforce (Outbound REST)
Salesforce App TypeExternal Client App

 

Salesforce Setup : Create an External Client App

Go to: Setup → App Manager → External Client Apps → External Client App Manager → New External Client App

  • Name the app and enable OAuth settings.
  • Under OAuth Scopes, select permissions like Full access or API access.

Screenshot 2026-09-17 145425.pngScreenshot 2026-09-17 145529.png

 

Note : Salesforce will generate a Client ID and Client Secret, which we will use to authenticate ServiceNow.🔑

 

ServiceNow Setup :

1. Application Registry (OAuth Provider) :

System OAuth → Application Registries → New → Connect to a third party OAuth Provider

 

FieldValue
Namee.g. Salesforce OAuth 2.0
Client IDConsumer Key from Salesforce
Client SecretConsumer Secret from Salesforce
Grant typeClient Credentials
Token URLhttps://<your-domain>/services/oauth2/token
Authorization URLhttps://<your-domain>/services/oauth2/authorize
Active✔️

 

Screenshot 2026-09-17 151431.png

 

2. REST Message :
System Web Services → REST Message → New

FieldValue
Namee.g. Salesforce Case Integration
Endpointhttps://<salesforce-instance>/services/data/v58.0/sobjects/Case
Authentication typeOAuth 2.0
OAuth profile<created_above>

Screenshot 2026-09-17 152618.pngScreenshot 2026-09-17 152717.png

 

Implementing Business Rule for dynamic creation :

  1. Create a Business Rule in ServiceNow that triggers on Incident creation.
  2. Call the Outbound REST Message in the Business Rule to send the incident data to Salesforce and create the case.
  3. Capture the Case ID from the response and update the Incident record with this ID.

Script :

(function executeRule(current, previous /*null when async*/ ) {

    // Add your code here
    try {
        var r = new sn_ws.RESTMessageV2('Salesforce Case Integration', 'POST');
        r.setStringParameterNoEscape('description', current.description);
        r.setStringParameterNoEscape('short_description', current.short_description);

        //override authentication profile 
        //authentication type ='basic'/ 'oauth2'
        //r.setAuthenticationProfile(authentication type, profile name);

        //set a MID server name if one wants to run the message on MID
        //r.setMIDServer('MY_MID_SERVER');

        //if the message is configured to communicate through ECC queue, either
        //by setting a MID server or calling executeAsync, one needs to set skip_sensor
        //to true. Otherwise, one may get an intermittent error that the response body is null
        //r.setEccParameter('skip_sensor', true);

        var response = r.execute();
        var responseBody = response.getBody();
        var httpStatus = response.getStatusCode();
    } catch (ex) {
        var message = ex.message;
    }
})(current, previous);

 

Testing the Integration :

  1. Create an incident in ServiceNow.
  2. The Business Rule will trigger, calling the REST Message to Salesforce.
  3. Same way create an User in ServiceNow.
  4. In Salesforce respective acoount will be created.

Screenshot 2026-09-17 154959.pngScreenshot 2026-09-17 154827.png

 

 

Conclusion

Finally you've successfully integrated ServiceNow with Salesforce using REST API and OAuth 2.0. One of the most valuable parts of this exercise was understanding how ServiceNow can communicate with external platforms securely through REST APIs and OAuth, rather than just working within the ServiceNow platform.

Also Refer the Official Docs for detailed understanding :

Integrating with Salesforce CRM

If you have any questions, feel free to reach out in the comments!

0 REPLIES 0