Zendesk - ServiceNow Integration

Ahmer Faraz1
Tera Contributor

Zendesk - ServiceNow Integration

1. Need to create an incident from the ServiceNow side and pass the value to zendesk side with the help of rest message and Business Rules.

I need to pass the incident filed value in the below format with a Business Rules :


{"request":{ "subject": "",

"collaborators": ["abc@xyz.com"],

"comment": {"body": "", "uploads":["",""]},

"can_be_solved_by_me": "true",

"organization_id": "",

"custom_fields":[{"id": "360046171833", "value": " "},

{"id": "360046171913", "value":" "},

{"id": "360046194634", "value":" "}

]}}

1 ACCEPTED SOLUTION

Sankar N
Kilo Guru

To create an incident in Zendesk from ServiceNow and pass the incident field value in the specified format using REST message and Business Rules, you can follow these steps:

  1. Create a REST message in ServiceNow to send the data to Zendesk. In the REST message, set the HTTP Method to POST and set the Endpoint URL to the Zendesk API endpoint for creating incidents.

  2. Create a Business Rule in ServiceNow to trigger when a new incident is created. In the Business Rule, write a script to format the incident data in the specified format and send it to Zendesk using the REST message created in Step 1.

Here's an example script that you can use in the Business Rule:

 

 

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

  // Get the incident data
  var subject = current.short_description;
  var body = current.description;
  var collaborators = ["abc@xyz.com"];
  var customFields = [
    {"id": "360046171833", "value": current.category},
    {"id": "360046171913", "value": current.subcategory},
    {"id": "360046194634", "value": current.impact}
  ];
  
  // Format the data as JSON
  var data = {
    "request": {
      "subject": subject,
      "collaborators": collaborators,
      "comment": {
        "body": body,
        "uploads": []
      },
      "can_be_solved_by_me": "true",
      "organization_id": "",
      "custom_fields": customFields
    }
  };
  var jsonData = JSON.stringify(data);

  // Send the data to Zendesk using the REST message
  var restMessage = new sn_ws.RESTMessageV2();
  restMessage.setEndpoint("<Zendesk API Endpoint URL for creating incidents>");
  restMessage.setHttpMethod("POST");
  restMessage.setRequestHeader("Content-Type", "application/json");
  restMessage.setRequestBody(jsonData);
  var response = restMessage.execute();

})(current, previous);

 

In the script above, replace <Zendesk API Endpoint URL for creating incidents> with the actual API endpoint URL for creating incidents in Zendesk.

This script gets the incident data from the current incident record in ServiceNow and formats it as a JSON object in the specified format. It then sends the JSON object to Zendesk using the REST message created in Step 1.

I hope this helps you create an incident in Zendesk from ServiceNow and pass the incident field value in the specified format using REST message and Business Rules.

 

Please mark my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

4 REPLIES 4

Sankar N
Kilo Guru

To create an incident in Zendesk from ServiceNow and pass the incident field value in the specified format using REST message and Business Rules, you can follow these steps:

  1. Create a REST message in ServiceNow to send the data to Zendesk. In the REST message, set the HTTP Method to POST and set the Endpoint URL to the Zendesk API endpoint for creating incidents.

  2. Create a Business Rule in ServiceNow to trigger when a new incident is created. In the Business Rule, write a script to format the incident data in the specified format and send it to Zendesk using the REST message created in Step 1.

Here's an example script that you can use in the Business Rule:

 

 

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

  // Get the incident data
  var subject = current.short_description;
  var body = current.description;
  var collaborators = ["abc@xyz.com"];
  var customFields = [
    {"id": "360046171833", "value": current.category},
    {"id": "360046171913", "value": current.subcategory},
    {"id": "360046194634", "value": current.impact}
  ];
  
  // Format the data as JSON
  var data = {
    "request": {
      "subject": subject,
      "collaborators": collaborators,
      "comment": {
        "body": body,
        "uploads": []
      },
      "can_be_solved_by_me": "true",
      "organization_id": "",
      "custom_fields": customFields
    }
  };
  var jsonData = JSON.stringify(data);

  // Send the data to Zendesk using the REST message
  var restMessage = new sn_ws.RESTMessageV2();
  restMessage.setEndpoint("<Zendesk API Endpoint URL for creating incidents>");
  restMessage.setHttpMethod("POST");
  restMessage.setRequestHeader("Content-Type", "application/json");
  restMessage.setRequestBody(jsonData);
  var response = restMessage.execute();

})(current, previous);

 

In the script above, replace <Zendesk API Endpoint URL for creating incidents> with the actual API endpoint URL for creating incidents in Zendesk.

This script gets the incident data from the current incident record in ServiceNow and formats it as a JSON object in the specified format. It then sends the JSON object to Zendesk using the REST message created in Step 1.

I hope this helps you create an incident in Zendesk from ServiceNow and pass the incident field value in the specified format using REST message and Business Rules.

 

Please mark my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hello @Sankar N 

 

 

Sending over all the values of your json, is totally possible with an OOTB solution or a 3th party solution like Exalate, which is a decentralized integration solution, where you can granuarly decide which data will be send over and applied.

 

In my opinion I would go that route, as you have limitless flexibility how you want to configure the product.

 

 

 

 

Rajani5
Tera Contributor

Should we need to create another BR for put method.how do we handle update ticket scenario I.e update in Servicenow incident should update in zendesk and vice verse.pls suggest

Josh Gold
Tera Expert

Try a no-code platform like Unito! It can sync Zendesk tickets to ServiceNow records in real-time without script or code. It's a lot simpler than trying to figure out complex configurations manually.