What is ServiceNow?
ServiceNow is a business service management platform that offers you IT support services, whether you are an IT business or handling the IT services. For reducing the work effort, getting work done with ease, enhancing resolution speed and minimizing cost,
ServiceNow and Salesforce integration benefits
ServiceNow and Salesforce both are the major CRM systems, ServiceNow integration with Salesforce offers any business to run smoothly. It eases the work by providing access to multiple apps and synchronizing the data faster. Here are some benefits
A step-by-step guide to integrate ServiceNow with Salesforce
Let’s start with Obtaining a Personal Developer Instance
2. Open the ‘Manage’ menu and click the ‘Instance’ menu item.
3. Click the ‘Request Instance’ button.
- Select a ServiceNow version for the instance.
- When the instance is assigned, the screen updates to display the instance URL and the admin credentials. Copy the admin password to the clipboard.
6. Click on the URL as shown in the attachment above it redirects to the login page use the Username and Password shown in the attachment above.
Here is the Apex Callout Code for the Case Insertion on the ServiceNow from the Salesforce.
The trigger for the Case insertion:
trigger ServiceNow on Case (after insert) {
for(Case c : Trigger.New){
nameofyourcalloutclass.servicenowPost(c.CaseNumber); }
}
Above is the trigger which fires when the new Case is generated from the Salesforce organization. Class is called from the trigger which contains the whole functionality.
Apex Class for the Callout.
public class InsertCase{
@future(callout = true)
public static void servicenowPost(String incidentCase){
Http http = new Http();
HttpRequest req = new HttpRequest();
HttpResponse res = new HttpResponse();
String username = ‘admin’;
String password = ‘$Test12345’;
Blob headerValue = Blob.valueOf (username + ‘:’ + password);
String authorizationHeader = ‘BASIC ‘+ EncodingUtil.base64Encode(headerValue); req.setHeader(‘Authorization’, authorizationHeader); req.setEndpoint(‘https://dev1111.service-now.com/api/now/v1/table/incident);
req.setMethod(‘POST’); req.setHeader(‘Content-Type’, ‘application/json’); JSONGenerator gen = JSON.createGenerator(true); gen.writeStartObject();
//you can add as many mappings as you want gen.writeStringField (‘servicenowField’, incidentCase);
gen.writeEndObject();
//you can now use String pretty as your body
String pretty = gen.getAsString();
req.setBody(pretty);
HttpResponse res = http.send(req); system.debug(res.getBody());
}
}
After creating Trigger and class, create a Case in your Salesforce organization and login to the ServiceNow instance. Search the Incident in the search menu and open the incident. Find the incident with the same case number on the ServiceNow instance.
Now the ServiceNow and Salesforce integration completed successfully, the features and functionalities of both the CRM systems can be used from one system.