The ServiceNow Microsoft Dynamics 365 integration enables bidirectional synchronization between Dynamics 365 cases and ServiceNow incidents, providing unified customer service management across both platforms. This integration is essential for organizations using Dynamics 365 for CRM while relying on ServiceNow for IT service management and enterprise service delivery. Customer data, case information, and resolution details flow seamlessly between systems to eliminate duplicate work and provide consistent customer experiences. The integration primarily uses the Microsoft Dynamics 365 spoke in Integration Hub with scheduled imports and real-time triggers for data synchronization. Bidirectional flows include case-to-incident creation, status updates, customer contact synchronization, and resolution tracking, with the integration residing in the Integration Hub module and leveraging Flow Designer for orchestration.
Prerequisites
- •ServiceNow Quebec release or later with Integration Hub Professional license
- •Microsoft Dynamics 365 Customer Service or Sales license with API access
- •Azure Active Directory tenant admin access for app registration
- •System Administrator or integration_admin role in ServiceNow
- •Microsoft Dynamics 365 System Administrator or System Customizer role
- •Valid SSL certificates for HTTPS communication between platforms
- •MID Server if accessing on-premises Dynamics 365 deployment
Architecture Overview
The integration leverages the Microsoft Dynamics 365 spoke in Integration Hub, which provides pre-built actions for common operations like Create Record, Update Record, and Query Records. Authentication is established through OAuth 2.0 using Azure app registrations, with credentials stored in Connection & Credential Aliases within ServiceNow's secure credential store. Data flows bidirectionally through Flow Designer orchestrations that can be triggered by scheduled jobs, business rules, or webhook endpoints, with outbound calls using the spoke's REST Message framework. A MID Server is required only for on-premises Dynamics 365 deployments, while cloud-to-cloud integrations communicate directly through HTTPS. Rate limiting considerations include Dynamics 365 API limits of 4,000 requests per user per 5-minute window and Service Protection API limits that throttle excessive requests, requiring retry logic and exponential backoff patterns in the integration flows.
Sourdough: ServiceNow Monitoring and Analytics
A Chrome extension for ServiceNow Admins and Developers with essential tools, analytics, graphs and monitoring features.
Free to install. Pro $5/month after a 14-day no-card trial.
Pro requires the ServiceNow admin role. Upgrade inside the extension.
Implementation Steps
Register Azure AD application for ServiceNow integration
Navigate to the Azure portal and access Azure Active Directory > App registrations to create a new application registration for ServiceNow. Set the redirect URI to your ServiceNow instance URL followed by '/oauth_redirect.do' and configure API permissions for Dynamics 365 including user_impersonation and offline_access scopes. Generate a client secret and note the Application ID, Directory ID, and client secret values as these will be required in ServiceNow credential configuration. Ensure the application has appropriate permissions to read and write Dynamics 365 data based on your integration requirements, and consider using separate app registrations for production and non-production environments.
Install and configure Microsoft Dynamics 365 spoke in ServiceNow
Navigate to System Applications > All Available Applications > All and search for 'Microsoft Dynamics 365' to install the official spoke from the ServiceNow Store. Once installed, navigate to Connections & Credentials > Credentials to create a new OAuth 2.0 credential record with credential name 'dynamics365_oauth'. Enter the Azure application ID as the client ID, paste the client secret in the client secret field, and set the OAuth Entity Profile to point to your Dynamics 365 instance. Configure the authorization URL as https://login.microsoftonline.com/{tenant-id}/oauth2/v2.0/authorize and token URL as https://login.microsoftonline.com/{tenant-id}/oauth2/v2.0/token, replacing {tenant-id} with your actual Azure tenant ID.
Create Connection Alias for Dynamics 365 endpoint
Navigate to Connections & Credentials > Connection & Credential Aliases and create a new alias named 'dynamics365_connection'. Set the connection URL to your Dynamics 365 instance URL (e.g., https://orgname.crm.dynamics.com) and associate it with the OAuth credential created in the previous step. Configure the connection type as 'HTTP(s)' and set appropriate timeout values such as 30 seconds for connection timeout and 60 seconds for read timeout. Test the connection by clicking the 'Test Connection' button to verify successful authentication and connectivity to your Dynamics 365 instance, ensuring the OAuth flow completes successfully and returns valid tokens.
Configure bidirectional data mapping for cases and incidents
Navigate to Process Automation > Flow Designer and create a new flow named 'Dynamics 365 Case to ServiceNow Incident Sync'. Add the Microsoft Dynamics 365 spoke action 'Query Records' as a trigger with entity set to 'incidents' (Dynamics cases) and configure field mapping between Dynamics case fields and ServiceNow incident fields. Map critical fields such as title to short_description, case description to description, customer information to caller_id, and priority levels between both systems. Create a second flow for the reverse direction named 'ServiceNow Incident to Dynamics 365 Case Sync' using business rules or scheduled jobs as triggers, ensuring proper field transformation and data validation occurs during the mapping process.
// Field mapping transform script for Dynamics to ServiceNow
var mapping = {
'title': inputs.dynamics_case.title || '',
'short_description': inputs.dynamics_case.title || '',
'description': inputs.dynamics_case.description || '',
'priority': mapPriority(inputs.dynamics_case.prioritycode),
'state': mapState(inputs.dynamics_case.statecode)
};
function mapPriority(dynamicsPriority) {
var priorityMap = {'1': '1', '2': '2', '3': '3'};
return priorityMap[dynamicsPriority] || '3';
}
function mapState(dynamicsState) {
var stateMap = {'0': '1', '1': '6', '2': '7'};
return stateMap[dynamicsState] || '1';
}Implement customer data synchronization between platforms
Create a scheduled import set to synchronize customer data from Dynamics 365 contacts and accounts to ServiceNow users and companies tables. Navigate to System Import Sets > Administration > Data Sources and create a new data source pointing to the Dynamics 365 Web API contacts endpoint using the connection alias configured earlier. Configure field mapping through transform maps to align Dynamics 365 contact fields like fullname, emailaddress1, and telephone1 with ServiceNow user fields such as name, email, and phone. Set up the import to run on a scheduled basis, typically every 4-6 hours, with proper error handling and duplicate prevention logic to maintain data consistency across both platforms.
// Transform script for Dynamics contact to ServiceNow user
var contact = source.getValue('fullname');
var email = source.getValue('emailaddress1');
var phone = source.getValue('telephone1');
if (email) {
var user = new GlideRecord('sys_user');
user.addQuery('email', email);
user.query();
if (!user.next()) {
target.name = contact;
target.email = email;
target.phone = phone;
target.active = true;
} else {
target.setDisplayValue('sys_id', user.sys_id);
}
}Set up real-time webhooks for immediate case synchronization
Configure Dynamics 365 webhooks to notify ServiceNow immediately when cases are created or updated by navigating to Dynamics 365 Settings > Customizations > Customize the System > Processes. Create new real-time workflows that trigger on case entity changes and send HTTP POST requests to ServiceNow Scripted REST API endpoints. In ServiceNow, navigate to System Web Services > Scripted REST APIs and create a new API named 'DynamicsWebhookReceiver' with resource methods to handle case creation and update notifications. Implement proper authentication and payload validation in the webhook receiver to ensure secure and reliable data transmission between systems.
(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
try {
var payload = request.body.data;
var caseId = payload.incidentid;
// Validate webhook source
if (!validateWebhookSignature(request)) {
response.setStatus(401);
return;
}
var incident = new GlideRecord('incident');
incident.addQuery('u_dynamics_case_id', caseId);
incident.query();
if (incident.next()) {
updateExistingIncident(incident, payload);
} else {
createNewIncident(payload);
}
response.setStatus(200);
} catch (e) {
gs.error('Dynamics webhook error: ' + e.message);
response.setStatus(500);
}
})(request, response);Configure error handling and retry mechanisms
Navigate to Flow Designer and enhance your integration flows with comprehensive error handling using Try-Catch blocks and retry logic for failed API calls. Configure exponential backoff retry patterns that respect Dynamics 365 rate limiting by implementing wait conditions between retry attempts, starting with 1-second delays and doubling up to maximum 60-second intervals. Set up monitoring and alerting by creating event rules that trigger when integration failures occur, sending notifications to integration administrators with detailed error information. Create a custom table to log all integration transactions, including success and failure details, API response codes, and retry attempts to provide audit trails and troubleshooting insights.
// Retry logic with exponential backoff
function callDynamicsAPI(action, retryCount) {
retryCount = retryCount || 0;
var maxRetries = 3;
var backoffDelay = Math.pow(2, retryCount) * 1000;
try {
var response = action.execute();
if (response.getStatusCode() == 200) {
return response;
} else if (response.getStatusCode() == 429 && retryCount < maxRetries) {
gs.sleep(backoffDelay);
return callDynamicsAPI(action, retryCount + 1);
}
} catch (e) {
if (retryCount < maxRetries) {
gs.sleep(backoffDelay);
return callDynamicsAPI(action, retryCount + 1);
}
throw e;
}
}Test integration flows and validate data synchronization
Create test cases in both Dynamics 365 and ServiceNow to validate bidirectional synchronization works correctly across all scenarios including create, update, and resolution workflows. Use the Flow Designer test functionality to execute flows manually with sample data, verifying field mappings, data transformations, and error handling paths work as expected. Navigate to System Logs > Outbound HTTP Requests to monitor API calls and response codes, ensuring successful communication with Dynamics 365 endpoints. Perform end-to-end testing by creating a case in Dynamics 365 and verifying it appears as an incident in ServiceNow within the expected timeframe, then update the incident in ServiceNow and confirm the changes sync back to Dynamics 365, validating complete integration functionality.
// Test script for validating integration
var testCase = {
title: 'Test Integration Case',
description: 'Testing ServiceNow integration',
prioritycode: 2,
customerid: 'test@company.com'
};
// Create test incident
var incident = new GlideRecord('incident');
incident.initialize();
incident.short_description = testCase.title;
incident.description = testCase.description;
incident.priority = '2';
var incidentId = incident.insert();
gs.info('Test incident created: ' + incidentId);
// Trigger sync flow
var flow = new sn_fd.FlowAPI();
flow.startFlow('dynamics365_incident_sync', {incident_id: incidentId});Common Use Cases
Escalate Dynamics 365 cases to ServiceNow for technical resolution
When Dynamics 365 customer service cases require technical expertise or IT infrastructure changes, they are automatically escalated to ServiceNow as incidents. The integration transfers customer contact information, case history, and priority levels to ensure ServiceNow technicians have complete context. Resolution details and status updates flow back to Dynamics 365 to keep customer service representatives informed. This use case typically involves cases related to software issues, system access problems, or requests requiring backend system modifications.
Synchronize customer master data across CRM and ITSM platforms
Customer contact information, company details, and organizational hierarchies are synchronized from Dynamics 365 to ServiceNow to maintain consistent customer data across platforms. This ensures ServiceNow incidents are properly associated with the correct customers and that customer service representatives in Dynamics 365 can see IT service history. The sync includes contact details, preferred communication methods, service level agreements, and customer tier information. Regular scheduled imports keep data current while webhook-based updates handle real-time changes for critical customer information.
Track IT service delivery metrics within Dynamics 365 customer records
ServiceNow incident resolution data, SLA compliance metrics, and service delivery statistics are pushed back to Dynamics 365 customer records to provide comprehensive customer service insights. Customer service representatives can view IT service history, response times, and recurring issues directly within the Dynamics 365 interface. This integration enables better customer conversations by providing complete service context and helps identify opportunities for proactive service improvements. The data includes incident counts, average resolution times, and customer satisfaction scores from ServiceNow.
Automate case routing based on ServiceNow service catalog requests
ServiceNow catalog requests that require customer communication or business approval are automatically converted to Dynamics 365 cases for proper customer service workflows. The integration maps technical service requests to customer-facing cases, ensuring appropriate follow-up and communication occurs. Business stakeholders can track request progress through Dynamics 365 while technical teams manage fulfillment in ServiceNow. This use case commonly applies to requests for new software access, hardware provisioning, or business process changes that require customer service coordination.
Unified reporting across customer service and IT service management
Data from both platforms is consolidated to create comprehensive reports showing complete customer service delivery across sales, support, and IT services. Integration flows extract key metrics and transaction data from both systems for loading into data warehouses or business intelligence platforms. This enables executive dashboards showing customer satisfaction trends, service delivery performance, and operational efficiency across all service channels. The unified data helps identify correlations between IT service quality and customer satisfaction, supporting data-driven service improvement initiatives.
Troubleshooting
OAuth token refresh fails with 'invalid_grant' error in credential logs
Check the Azure app registration redirect URI matches exactly with your ServiceNow instance URL including the '/oauth_redirect.do' suffix and ensure there are no trailing spaces. Navigate to Connections & Credentials > Credentials and re-authorize the OAuth credential by clicking 'Get OAuth Token' to refresh the authorization code. Verify the Azure app registration has not expired and that the client secret is still valid, as expired secrets will cause token refresh failures. If the issue persists, check that the system clock on your ServiceNow instance is synchronized as OAuth tokens are time-sensitive.
Dynamics 365 API returns 429 'Too Many Requests' errors during data sync
Implement exponential backoff retry logic in your integration flows and reduce the frequency of scheduled imports to respect Dynamics 365 service protection API limits. Navigate to System Logs > Outbound HTTP Requests to identify which API endpoints are being throttled and adjust batch sizes to process smaller record sets per API call. Consider spreading data sync operations across different time periods to avoid concentrated API usage and implement flow control mechanisms that pause processing when rate limits are encountered. Add monitoring to track API consumption patterns and proactively adjust integration timing before limits are reached.
Webhook payloads from Dynamics 365 not creating ServiceNow records
Navigate to System Logs > System Log > All to check for JavaScript errors in your Scripted REST API webhook receiver and verify the payload structure matches your parsing logic. Check that the webhook endpoint URL is accessible from the internet and that your ServiceNow instance firewall rules allow inbound connections from Microsoft's IP ranges. Validate webhook payload signatures if implemented and ensure the Content-Type header handling in your REST API matches what Dynamics 365 sends. Use the REST API Explorer to test your webhook endpoint manually with sample Dynamics 365 payloads to isolate parsing issues.
Field mapping errors cause data transformation failures in Flow Designer
Review the Flow Designer execution details to identify which specific field mappings are failing and check for null value handling in your transformation scripts. Navigate to the failed flow execution logs and examine the input/output data to verify source field names match exactly with Dynamics 365 entity metadata. Add defensive coding practices like null checks and default value assignments in transformation scripts to handle missing or malformed data gracefully. Test field mappings with edge cases including empty strings, special characters, and maximum field length values to ensure robust data transformation.
Duplicate records created during bidirectional synchronization
Implement unique identifier tracking by adding custom fields to store external system record IDs and use these for duplicate detection before creating new records. Create business rules or before insert scripts that query for existing records using external IDs, email addresses, or other unique identifiers to prevent duplicates. Navigate to your Flow Designer integration flows and add conditional logic that checks for existing records before executing create actions. Consider implementing record locking or synchronization flags to prevent race conditions when both systems attempt to create or update records simultaneously.
Integration performance degrades with large dataset synchronization
Optimize API queries by implementing field selection to retrieve only necessary data fields and use pagination with smaller batch sizes (50-100 records) instead of large single requests. Navigate to your scheduled import jobs and implement incremental sync patterns using last modified date filters to process only changed records since the last sync. Add parallel processing capabilities by creating multiple flow instances that handle different data subsets concurrently while respecting API rate limits. Monitor database performance impacts and consider off-peak scheduling for large data synchronization operations to avoid impacting user experience.
Pro Tips
- →Implement delta synchronization by tracking last modified timestamps in both systems to avoid processing unchanged records, significantly improving performance and reducing API consumption. Create custom fields on relevant tables to store the last sync timestamp and use these values in OData filters when querying Dynamics 365, reducing data transfer volumes by up to 90% in steady-state operations.
- →Use Connection & Credential Aliases with multiple credential entries for different environments (dev, test, prod) to enable seamless promotion of integration flows across instances. Set up environment-specific connection aliases that automatically switch credentials based on the ServiceNow instance, eliminating manual credential updates during deployments and reducing configuration errors.
- →Leverage Dynamics 365 alternate keys for record matching instead of relying solely on GUIDs, as alternate keys provide more reliable synchronization when records are created in different environments. Configure composite alternate keys using business-meaningful fields like email addresses or external system IDs to enable robust duplicate detection and data consistency validation.
- →Implement comprehensive audit logging by creating custom tables that capture all integration transactions with payload details, response codes, and processing times. This audit trail is invaluable for troubleshooting, compliance reporting, and performance optimization, especially when dealing with data discrepancies between systems weeks or months after initial synchronization.
- →Configure Flow Designer subflows for common operations like field mapping and error handling to promote reusability and consistency across multiple integration flows. Create a library of reusable subflows for tasks like customer lookup, priority mapping, and status translation that can be maintained centrally and updated across all integration points simultaneously.
- →Set up proactive monitoring using ServiceNow Event Management to create events when integration failures occur, API response times exceed thresholds, or data quality issues are detected. Configure event rules that automatically create incidents for integration support teams and implement escalation procedures for critical synchronization failures that could impact business operations.
Known Limitations
- —Dynamics 365 Web API enforces service protection limits of 4,000 requests per user per 5-minute window and 20,000 requests per user per 24-hour period, requiring careful batch sizing and retry logic to avoid throttling. These limits are shared across all applications using the same user credentials, potentially causing conflicts in environments with multiple integrations or heavy API usage patterns.
- —Real-time synchronization latency can range from 30 seconds to several minutes depending on Flow Designer execution queues and Dynamics 365 webhook delivery delays, making true real-time integration challenging for time-critical processes. Consider this latency when designing business processes that depend on immediate data availability across both platforms.
- —The Microsoft Dynamics 365 spoke supports only cloud-based Dynamics 365 instances and requires a MID Server for on-premises deployments, adding infrastructure complexity and potential network connectivity challenges. On-premises integrations also require additional security considerations including firewall rules and certificate management that cloud-to-cloud integrations avoid.
- —Complex data transformations requiring multiple API calls or extensive business logic can impact Flow Designer performance and may exceed execution time limits, particularly when processing large datasets or performing complex field mappings. Consider using scheduled jobs or custom scripted solutions for heavy data processing requirements that exceed Flow Designer capabilities.
- —OAuth token management requires periodic re-authorization for long-running integrations, and Azure AD conditional access policies or multi-factor authentication requirements can complicate automated token refresh processes. Plan for manual re-authorization procedures and consider service account configurations that minimize authentication complications.
Frequently Asked Questions
Can I sync custom fields between Dynamics 365 and ServiceNow?
Yes, custom fields can be synchronized by modifying the field mapping configurations in your Flow Designer integration flows and ensuring proper data type compatibility between platforms. You'll need to identify the custom field schema names in Dynamics 365 (typically prefixed with organization name) and map them to corresponding custom fields in ServiceNow using transform scripts. The Microsoft Dynamics 365 spoke supports custom entity fields through the Web API, but you may need to adjust security permissions in Dynamics 365 to allow API access to custom fields. Consider field length limits and data type conversions when mapping custom fields, especially for choice lists and lookup fields that may not have direct equivalents.
How do I handle different priority and status values between the two systems?
Implement mapping tables or transform scripts that convert between different priority and status schemes using lookup dictionaries or case statements in your Flow Designer data transformations. Create reference tables in ServiceNow that store the mapping relationships between Dynamics 365 choice values and ServiceNow choice values, allowing for easy maintenance and updates without modifying integration code. Use the sys_choice table to understand available options in ServiceNow and query Dynamics 365 metadata to identify valid choice values in that system. Consider implementing default value handling for unmapped choices and logging mechanisms to identify new values that need mapping rules added.
What happens if one system is unavailable during synchronization?
The integration includes retry mechanisms with exponential backoff that will attempt to resend failed requests when systems become available again, but you should implement queue-based processing for critical data synchronization. Flow Designer automatically retries failed actions up to the configured limit, and you can extend this with custom error handling that logs failed transactions for manual processing later. Consider implementing a holding table or queue system that stores pending synchronization requests when target systems are unavailable, allowing for batch processing once connectivity is restored. Monitor system availability and configure alerting to notify administrators when extended outages may require manual intervention or alternative processing procedures.
Can I integrate with multiple Dynamics 365 organizations from one ServiceNow instance?
Yes, you can configure multiple Connection & Credential Aliases pointing to different Dynamics 365 organizations and create separate integration flows for each organization using different connection aliases. Each organization will require its own Azure app registration and OAuth credentials stored as separate credential records in ServiceNow. Use naming conventions that clearly identify which flows and credentials belong to which Dynamics organization to avoid configuration errors and data cross-contamination. Consider using different ServiceNow tables or field markers to distinguish records that originated from different Dynamics organizations, especially if data needs to remain segregated for security or compliance reasons.
How do I test the integration in a development environment?
Set up separate Azure app registrations for development and production environments with appropriate redirect URIs pointing to your development ServiceNow instance, and create corresponding Connection & Credential Aliases for each environment. Use Dynamics 365 sandbox or trial organizations for development testing to avoid impacting production data, and implement data masking or synthetic test data strategies for realistic testing scenarios. The Flow Designer Test functionality allows you to execute flows with sample data without triggering actual API calls, which is useful for validating flow logic and field mappings. Create automated test scripts using ServiceNow's Test Management framework to validate integration functionality as part of your deployment pipeline and ensure changes don't break existing integration patterns.
What ServiceNow roles are required for setting up and managing this integration?
Users need the admin or integration_admin role to configure Connection & Credential Aliases, install spokes, and create Flow Designer flows, while the oauth_entity_admin role is required for managing OAuth credentials and tokens. Developers creating custom Scripted REST APIs or transform scripts need the web_service_admin role and appropriate table access for the specific records being synchronized. Day-to-day monitoring and troubleshooting can be performed by users with the flow_operator role combined with read access to system logs and integration monitoring tables. Consider creating a custom role that combines necessary permissions for integration administrators while limiting access to other system administration functions for security and change control purposes.
How can I monitor integration performance and data synchronization health?
Use the Flow Designer execution history and Performance Analytics to monitor flow execution times, success rates, and error patterns, while the Outbound HTTP Request log provides detailed API call information including response codes and processing times. Create custom dashboards using ServiceNow reporting that track key metrics like daily sync volumes, error rates, and data quality indicators such as failed field mappings or duplicate detection events. Implement custom Event Management rules that generate alerts when integration metrics exceed defined thresholds, such as elevated error rates or extended processing times that might indicate system performance issues. Consider integrating with external monitoring tools through ServiceNow's REST APIs to include integration health metrics in broader infrastructure monitoring dashboards.
Test Your Knowledge
Quick 3-question quiz — see how your ServiceNow skills stack up.
A list view on a table with millions of records is slow. Best fix?
Select an answer to continue