Integrations

ServiceNow Salesforce Integration Guide

advancedOAuth 2.0 Authorization Code Grant with refresh tokenSalesforce

The ServiceNow Salesforce integration enables seamless data synchronization between ServiceNow's IT service management platform and Salesforce's CRM system, solving the critical business problem of data silos between customer-facing and IT operations teams. This integration is primarily used by enterprise organizations where sales teams in Salesforce need visibility into IT incidents affecting their customers, and IT teams need access to customer account data for proper incident prioritization and CMDB enrichment. The integration supports bidirectional data flows between Salesforce Cases and ServiceNow Incidents, unidirectional sync of Salesforce Accounts to ServiceNow CMDB, and real-time webhook-based triggers for immediate data synchronization. Built using ServiceNow's Integration Hub Salesforce spoke and leveraging OAuth 2.0 authentication through Salesforce Connected Apps, this integration operates within ServiceNow's Integration Hub module with support for both scheduled bulk imports and event-driven real-time sync.

Prerequisites

  • ServiceNow Rome or later with Integration Hub Professional license
  • Salesforce Enterprise, Performance, or Unlimited edition with API access enabled
  • System Administrator role in both ServiceNow and Salesforce environments
  • Salesforce Connected App creation permissions for OAuth configuration
  • ServiceNow roles: admin, integration_hub_admin, and rest_service roles
  • Active MID Server (if connecting to Salesforce through private network)
  • Salesforce API usage allocation (minimum 1000 API calls per day recommended)

Architecture Overview

This integration utilizes ServiceNow's official Integration Hub Salesforce spoke, which provides pre-built Actions for common Salesforce operations including Create Record, Update Record, Query Records, and Get Record Details. Authentication is established through OAuth 2.0 using Salesforce Connected Apps, with credentials securely stored in ServiceNow's Connection & Credential Alias records that encrypt sensitive tokens and refresh tokens. Data flows bidirectionally with ServiceNow Incidents syncing to Salesforce Cases via scheduled Flow Designer flows, while Salesforce Case updates trigger outbound messages or platform events that invoke ServiceNow Scripted REST APIs for real-time sync. No MID Server is required for standard cloud-to-cloud connectivity since the integration uses direct HTTPS calls to Salesforce REST APIs, though a MID Server may be needed if your ServiceNow instance requires proxy routing. Rate limiting follows Salesforce's standard API limits (typically 15,000-100,000 calls per 24 hours depending on edition), with the Integration Hub automatically handling token refresh and providing retry mechanisms for failed API calls.

Sourdough
Chrome Extension

Sourdough: ServiceNow Monitoring and Analytics

A Chrome extension for ServiceNow Admins and Developers with essential tools, analytics, graphs and monitoring features.

Instance HealthGraphs & ChartsAPI HealthDeveloper ToolsQuick SearchInstance Switcher
Add to Chrome

Free to install. Pro $5/month after a 14-day no-card trial.
Pro requires the ServiceNow admin role. Upgrade inside the extension.

Overview
Tasks
CMDB
API
Metrics
Monitor
Internals
Instance:sourdoughdev·Version:Yokohama
Instance StateONLINE
System StatusFully Operational
Session Timeout90 minutes
Logged-In Sessions2 (20 active)
Build Nameyokohama-12-18-2024_p1
IP Address10.159.128.43
Instance HealthHealth Score: 90%
🔥 5dSourdough (Chrome Plugin)Dark Mode

Implementation Steps

1

Create Salesforce Connected App for OAuth integration

Navigate to Salesforce Setup > Apps > App Manager and click 'New Connected App' to create the OAuth configuration required for ServiceNow authentication. Fill in the Connected App Name (e.g., 'ServiceNow Integration'), API Name, and Contact Email, then enable OAuth Settings with 'Full access (full)' and 'Perform requests on your behalf at any time (refresh_token, offline_access)' scopes selected. Set the Callback URL to your ServiceNow instance URL followed by '/oauth_redirect.do' (e.g., https://dev12345.service-now.com/oauth_redirect.do) and save the configuration. After creation, click 'View' on your Connected App, then 'Manage Consumer Details' to retrieve the Consumer Key and Consumer Secret values that will be needed in ServiceNow credential configuration.

2

Configure ServiceNow Connection and Credential records

Navigate to Connections & Credentials > Connections and create a new Connection record with Name 'Salesforce Production', Connection alias 'salesforce_prod', and Connection type 'HTTP(s)'. Set the Connection URL to 'https://login.salesforce.com' (or 'https://test.salesforce.com' for sandbox environments) and save the record. Next, navigate to Connections & Credentials > Credentials and create a new OAuth 2.0 credential with Name 'Salesforce OAuth Credential' and Type 'OAuth 2.0'. Fill in the Authorization URL 'https://login.salesforce.com/services/oauth2/authorize', Token URL 'https://login.salesforce.com/services/oauth2/token', Client ID (Consumer Key from step 1), Client Secret (Consumer Secret from step 1), and Default Grant Type 'Authorization Code', then associate this credential with your Connection record.

3

Complete OAuth authorization flow in ServiceNow

Open the Credential record created in step 2 and click the 'Get OAuth Token' button to initiate the authorization flow, which will redirect you to Salesforce login page in a new browser window. Log in with your Salesforce administrator credentials and click 'Allow' to grant ServiceNow access to your Salesforce org, ensuring the OAuth scopes match those configured in your Connected App. After successful authorization, you'll be redirected back to ServiceNow where the Access Token and Refresh Token fields should now be populated automatically. Verify the token acquisition by checking that the 'Valid' field shows true and the 'Expires' field shows a future timestamp, indicating successful OAuth handshake completion.

4

Install and configure Salesforce Integration Hub spoke

Navigate to Integration Hub > Spokes and search for 'Salesforce' to locate the official ServiceNow Salesforce spoke, then click 'Install' if not already present in your environment. After installation, navigate to Integration Hub > Connections and create a new Connection Alias with Name 'Salesforce Connection', Type 'HTTP', and Connection pointing to the Connection record created in step 2. Configure the Connection Alias to use the OAuth credential from step 2 and test the connection by clicking 'Test Connection' to verify authentication is working properly. The spoke provides Actions including 'Create Salesforce Record', 'Update Salesforce Record', 'Query Salesforce Records', and 'Get Salesforce Record' that will be used in your integration flows.

5

Create bidirectional sync Flow Designer flows for Case-Incident integration

Navigate to Process Automation > Flow Designer and create a new flow named 'ServiceNow Incident to Salesforce Case Sync' with trigger 'Record Inserted or Updated' on the Incident table. Add condition logic to filter for incidents where State changes to 'In Progress' or 'Resolved' and Customer field is populated, then configure the 'Create Salesforce Record' spoke action to create a Case with Subject mapped to Incident Short Description, Description to Incident Description, and Priority mapped using transform logic (1=High, 2=Medium, 3=Low). For the reverse direction, create another flow 'Salesforce Case to ServiceNow Incident Sync' triggered by a scheduled job that queries Salesforce Cases modified in the last hour using the 'Query Salesforce Records' action. Map the Salesforce Case fields to corresponding ServiceNow Incident fields and include logic to either update existing incidents (using a correlation ID) or create new incidents based on whether a matching record exists.

ServiceNow Script
// Transform script for Priority mapping in Flow Designer
(function transform(source) {
    var priorityMap = {
        '1': 'High',
        '2': 'Medium', 
        '3': 'Low',
        '4': 'Planning',
        '5': 'Planning'
    };
    return priorityMap[source] || 'Medium';
})(fd_data.current.priority);
6

Configure Salesforce Account to ServiceNow CMDB synchronization

Create a scheduled Flow Designer flow named 'Salesforce Account to CMDB Company Sync' with a daily schedule trigger to synchronize Salesforce Account records to ServiceNow's Company table in the CMDB. Use the 'Query Salesforce Records' spoke action with SOQL query 'SELECT Id, Name, BillingStreet, BillingCity, BillingState, Phone, Website, LastModifiedDate FROM Account WHERE LastModifiedDate >= YESTERDAY' to retrieve recently modified accounts. Configure field mappings where Salesforce Account Name maps to Company Name, BillingStreet and BillingCity combine to form Company Street, BillingState maps to State/Province, and Website maps to Web site fields. Include duplicate prevention logic by checking if a Company record with the same name already exists using a GlideRecord query, and if found, update the existing record rather than creating a duplicate entry.

ServiceNow Script
// Duplicate check logic in Flow Designer script
var gr = new GlideRecord('core_company');
gr.addQuery('name', fd_data.salesforce_account.Name);
gr.query();
if (gr.next()) {
    fd_data.company_sys_id = gr.getUniqueValue();
    fd_data.update_existing = true;
} else {
    fd_data.update_existing = false;
}
7

Set up real-time webhook integration using Scripted REST APIs

Navigate to System Web Services > Scripted REST APIs and create a new API named 'Salesforce Webhook Handler' with Base API path '/api/salesforce/webhook' to receive real-time notifications from Salesforce. Create a POST resource method named 'handleCaseUpdate' that processes incoming Salesforce Case update notifications by parsing the JSON payload and updating corresponding ServiceNow Incident records. In the Scripted REST API, implement authentication verification using a shared secret or Salesforce certificate validation to ensure webhook security and prevent unauthorized access. Configure the corresponding Salesforce Outbound Message or Platform Event in Salesforce Setup > Workflow Rules or Process Builder to send notifications to your ServiceNow webhook URL when Case records are modified, ensuring the endpoint URL matches your ServiceNow instance domain followed by the API path.

ServiceNow Script
(function process(request, response) {
    var payload = request.body.data;
    var caseId = payload.Id;
    var caseStatus = payload.Status;
    
    // Find corresponding incident by external reference
    var incident = new GlideRecord('incident');
    incident.addQuery('u_salesforce_case_id', caseId);
    incident.query();
    
    if (incident.next()) {
        incident.setValue('state', mapSalesforceStatusToIncidentState(caseStatus));
        incident.update();
        response.setStatus(200);
        response.getStreamWriter().writeString('Success');
    } else {
        response.setStatus(404);
        response.getStreamWriter().writeString('Incident not found');
    }
})(request, response);
8

Test integration flows and validate data synchronization

Create a test Incident record in ServiceNow with all required fields populated including a customer reference, then monitor the Flow Designer execution details to verify the 'ServiceNow Incident to Salesforce Case Sync' flow triggers correctly and successfully creates a corresponding Case in Salesforce. Verify field mapping accuracy by comparing the created Salesforce Case values against the source ServiceNow Incident, checking that Priority, Description, and Subject fields contain the expected transformed data. Test the reverse synchronization by updating the Salesforce Case status or priority and confirming that the changes reflect in the corresponding ServiceNow Incident within the expected timeframe (either through scheduled job or webhook depending on your configuration). Validate the CMDB sync by checking that Salesforce Account records appear as Company records in ServiceNow's CMDB with proper field mapping and no duplicate entries, and monitor Integration Hub logs under System Logs > Integration Hub Logs for any error messages or failed API calls.

ServiceNow Script
// Test script to validate sync status
var testIncident = new GlideRecord('incident');
testIncident.addQuery('u_salesforce_case_id', '!=', '');
testIncident.addQuery('sys_created_on', '>', gs.daysAgoStart(1));
testIncident.query();
gs.info('Found ' + testIncident.getRowCount() + ' synced incidents in last 24 hours');

while (testIncident.next()) {
    gs.info('Incident: ' + testIncident.number + ' synced with Salesforce Case: ' + testIncident.u_salesforce_case_id);
}

Common Use Cases

Customer-impacting incident escalation to sales teams

When a high-priority incident affects a customer's production environment, the incident automatically syncs to Salesforce as a Case assigned to the customer's account team. This enables sales representatives to proactively communicate with customers about service disruptions and provide status updates without needing direct access to ServiceNow. The integration includes automatic priority mapping and real-time status updates, ensuring sales teams have immediate visibility into IT issues that could impact customer relationships and renewal discussions.

Customer account data enrichment for CMDB accuracy

Salesforce Account records automatically sync to ServiceNow's CMDB as Company records, enriching IT asset management with current customer contact information, billing addresses, and organizational details. This synchronization ensures that when incidents are created against customer infrastructure, technicians have access to up-to-date customer information including primary contacts, support tier levels, and contractual obligations. The integration prevents duplicate company records and maintains data consistency between sales and IT systems.

Service request fulfillment tracking for customer success

When customers submit service requests through Salesforce Cases (such as new user provisioning or software installations), these automatically create corresponding ServiceNow requests with proper categorization and assignment. Customer success managers can track fulfillment progress directly in Salesforce without requiring ServiceNow access, while IT teams work within their native platform. Status updates, completion notifications, and SLA compliance metrics sync back to Salesforce for comprehensive customer service reporting.

Post-sales implementation project coordination

For enterprise customers requiring complex technical implementations, Salesforce Opportunities with specific product configurations automatically generate ServiceNow Project records with associated tasks and timelines. Implementation consultants and technical teams coordinate project delivery within ServiceNow while sales teams monitor progress and milestone completion through Salesforce dashboards. This integration ensures seamless handoff from sales to delivery teams with complete project visibility and automated progress reporting.

Customer satisfaction feedback integration for service improvement

After incident resolution in ServiceNow, customer satisfaction surveys and feedback collected through Salesforce Cases automatically update the corresponding ServiceNow incident records with CSAT scores and comments. This enables IT service management teams to analyze customer satisfaction trends, identify recurring issues affecting customer experience, and prioritize service improvements based on direct customer feedback. The integration supports automated escalation of low satisfaction scores to management for immediate attention.

Troubleshooting

OAuth token refresh fails with 'invalid_grant' error in Integration Hub logs

This typically occurs when the refresh token has expired or been revoked in Salesforce, often due to password changes or security policy updates. Navigate to your Salesforce Connected App and verify that the 'Refresh Token Policy' is set to 'Refresh token is valid until revoked' rather than time-based expiration. In ServiceNow, delete the existing OAuth credential and recreate it following the authorization flow in step 3, ensuring you're logging in with the same Salesforce user account that has API permissions. Check Salesforce Setup > Login History to confirm the OAuth authorization completed successfully.

Salesforce API rate limit exceeded causing Flow Designer actions to fail

Monitor your Salesforce API usage in Setup > System Overview > API Usage to identify if you're approaching your daily API call limits, which vary by Salesforce edition (15,000 for Enterprise, 100,000 for Unlimited). Implement batch processing in your Flow Designer flows by using scheduled triggers that process records in smaller chunks rather than individual record triggers that generate excessive API calls. Configure the Integration Hub spoke actions with appropriate retry delays and consider implementing exponential backoff logic in custom scripts to handle temporary rate limit responses (HTTP 429 status codes) gracefully.

Field mapping errors when Salesforce picklist values don't match ServiceNow choice lists

Create transform scripts in your Flow Designer actions that include comprehensive value mapping logic and default fallback values for unmapped options. Use the Salesforce Describe API to retrieve current picklist values and compare them against ServiceNow choice lists, documenting any discrepancies in a mapping table stored as a ServiceNow system property. Implement logging in your transform scripts to capture unmapped values for analysis, and consider creating a scheduled maintenance flow that alerts administrators when new unmapped values are encountered during synchronization.

Duplicate records created when sync logic fails to find matching records

Review your record matching logic to ensure it's using reliable unique identifiers rather than names or descriptions that might change over time. Implement a correlation ID field (like u_salesforce_id) in your ServiceNow tables and populate it during initial record creation to establish permanent links between systems. Add duplicate prevention logic that performs multiple matching attempts using different criteria (external ID first, then name and date combinations) and includes manual duplicate resolution workflows for edge cases where automated matching fails.

Webhook notifications from Salesforce not reaching ServiceNow Scripted REST API

Verify that your ServiceNow instance can receive inbound HTTPS traffic by testing the webhook URL directly using a tool like Postman or curl, checking for firewall or network restrictions that might block Salesforce's outbound traffic. In Salesforce Setup > Outbound Messages or Platform Events, confirm the endpoint URL exactly matches your ServiceNow Scripted REST API path including proper HTTPS and domain formatting. Check ServiceNow's Scripted REST API execution logs under System Logs > Scripted REST APIs to see if requests are being received but failing during processing, and verify that your API authentication logic properly validates Salesforce webhook signatures.

Integration Hub Connection test passes but spoke actions fail with authentication errors

This often indicates that while basic connectivity works, the OAuth token doesn't have sufficient permissions for the specific Salesforce objects or operations being attempted. Review the Salesforce Connected App OAuth scopes and ensure 'Full access (full)' is granted, then verify the connected user has appropriate profile permissions for the objects being accessed (Cases, Accounts, etc.). Clear the Integration Hub connection cache by deactivating and reactivating the Connection Alias, force a token refresh by clicking 'Get OAuth Token' again in the credential record, and test with a simplified spoke action like 'Get Record' before attempting complex operations like record creation or bulk queries.

Pro Tips

  • Implement correlation ID fields (like u_salesforce_case_id, u_salesforce_account_id) in your ServiceNow tables to maintain permanent links between synchronized records, preventing duplicate creation and enabling efficient updates. Use these fields as indexed database columns for faster lookup performance and include them in all sync flows for reliable record matching.
  • Configure Integration Hub retry policies and error handling workflows to automatically handle transient API failures, network timeouts, and rate limiting scenarios without manual intervention. Set up email notifications for integration administrators when critical sync failures occur, but avoid alerting for temporary issues that resolve automatically through retry logic.
  • Use Salesforce Platform Events instead of Outbound Messages for real-time notifications when possible, as they provide better scalability, retry capabilities, and detailed delivery tracking compared to traditional workflow-based outbound messages. Platform Events also support event replay functionality for better reliability during ServiceNow maintenance windows.
  • Implement field-level change detection in your Flow Designer flows to sync only modified data rather than full record updates, reducing API call consumption and improving performance. Store hash values or last-modified timestamps to compare against incoming data and skip unnecessary updates when no changes have occurred.
  • Create comprehensive logging and monitoring dashboards that track sync success rates, API usage trends, and data quality metrics across your Salesforce integration. Use ServiceNow's Integration Hub dashboard widgets and custom Performance Analytics datasets to provide visibility into integration health and identify optimization opportunities.
  • Schedule bulk synchronization jobs during off-peak hours and implement incremental sync patterns that process only records modified within specific time windows rather than full dataset refreshes. This approach minimizes impact on system performance while ensuring data consistency between platforms.

Known Limitations

  • Salesforce API rate limits vary significantly by edition and can impact sync frequency, with Enterprise edition providing 15,000 API calls per 24 hours while Unlimited provides 100,000 calls, requiring careful planning for high-volume synchronization scenarios. Integration Hub doesn't automatically queue failed requests beyond basic retry attempts, so sustained rate limiting can cause data sync delays requiring manual intervention.
  • Real-time bidirectional synchronization can create infinite loops if not properly designed with loop prevention logic, particularly when both systems trigger updates simultaneously on the same record. ServiceNow's Integration Hub lacks built-in loop detection, requiring custom correlation tracking and synchronization state management to prevent circular update scenarios.
  • Large dataset synchronizations (over 10,000 records) may exceed ServiceNow's transaction timeout limits or Salesforce's single API call result size restrictions, requiring complex pagination and batch processing logic that increases implementation complexity. The Integration Hub Salesforce spoke doesn't automatically handle bulk API operations, limiting throughput for initial data migration scenarios.
  • Field-level security and sharing rules in Salesforce are enforced during API operations, potentially causing sync failures for records that the connected user cannot access or modify based on their profile and permission sets. This requires careful planning of the integration user's permissions and may necessitate separate integration users for different types of data access.

Frequently Asked Questions

Can I sync custom fields between Salesforce and ServiceNow tables?

Yes, both custom Salesforce fields and ServiceNow table columns can be synchronized through the Integration Hub spoke actions by configuring explicit field mappings in your Flow Designer flows. You'll need to reference Salesforce custom fields using their API names (ending with __c) and ensure the ServiceNow destination fields have compatible data types. Create transform scripts in Flow Designer to handle any data type conversions or validation requirements between the custom fields.

How do I handle Salesforce sandbox to ServiceNow development instance integration?

Create separate Connection and Credential records for your Salesforce sandbox environment using the sandbox login URL (https://test.salesforce.com) instead of production (https://login.salesforce.com) in the OAuth configuration. You'll need a separate Connected App in your Salesforce sandbox with its own Consumer Key and Consumer Secret values. Use different Connection Alias names like 'Salesforce Sandbox' to distinguish between environments and ensure your Flow Designer flows reference the correct connection based on the ServiceNow instance type.

What happens if my ServiceNow instance goes down during a sync operation?

Salesforce Outbound Messages have built-in retry mechanisms that will attempt to deliver webhook notifications for up to 24 hours with exponential backoff, so temporary ServiceNow outages won't cause permanent data loss. However, Integration Hub flows initiated from ServiceNow that fail mid-execution won't automatically retry, requiring manual reprocessing or custom error recovery flows. Consider implementing health check endpoints in your Scripted REST APIs and monitoring ServiceNow's Integration Hub logs to identify and recover from any missed synchronizations after outages.

Can I use this integration with Salesforce Professional or Standard editions?

No, this integration requires Salesforce Enterprise edition or higher because API access is not available in Professional or Standard editions, and these lower tiers don't support Connected Apps for OAuth authentication. Additionally, features like Outbound Messages and Platform Events used for real-time synchronization are only available in higher Salesforce editions. If you're using Salesforce Professional edition, consider upgrading or using alternative integration methods like email-to-case functionality combined with ServiceNow email processing.

How do I troubleshoot Integration Hub flows that show 'Completed with Errors' status?

Navigate to Process Automation > Flow Designer and open the specific flow execution that failed, then examine the Action Details section to identify which spoke action encountered errors and review the detailed error messages. Common issues include authentication failures (check Connection Alias configuration), field mapping errors (verify Salesforce object permissions), or data validation failures (ensure required fields are populated). Use the Integration Hub Logs under System Logs to see detailed API request/response information and enable debug logging on your Connection Alias for more verbose troubleshooting information.

Is it possible to sync ServiceNow attachments to Salesforce Case attachments?

Yes, but this requires custom development using Salesforce's ContentVersion and ContentDocumentLink objects through REST API calls since the standard Integration Hub spoke doesn't include attachment synchronization actions. You'll need to create custom Flow Designer scripts that read ServiceNow attachment records, encode file content in base64 format, and use the 'Create Salesforce Record' action to create ContentVersion records linked to the appropriate Salesforce Case. Be aware that large file synchronization can quickly consume API call limits and may require specialized error handling for file encoding issues.

What's the recommended approach for handling timezone differences in datetime field synchronization?

ServiceNow stores datetime values in UTC by default while Salesforce datetime fields are timezone-aware, so implement timezone conversion logic in your Flow Designer transform scripts using ServiceNow's GlideDateTime class and the gs.getUser().getTimeZone() method. Configure your field mappings to explicitly handle timezone conversion based on user preferences or organizational defaults, and consider storing timezone information as metadata to ensure bidirectional conversions maintain accuracy. Test datetime synchronization thoroughly across different user timezones to prevent scheduling and SLA calculation errors.

Test Your Knowledge

Quick 3-question quiz — see how your ServiceNow skills stack up.

Question 1 of 3Performance

A list view on a table with millions of records is slow. Best fix?

Select an answer to continue