The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Updating tickets from Smartsheet to Servicenow

varunkumar1
Tera Contributor

Hi Team,

I have integrated Servicenow (incident table)with Smart sheet.

On creating incident ticket on servicenow instance, integration triggers and creates a smart sheet and copies incident record data into smart sheet. 

Now I am looking for reverse integration i.e on updating incident record in smart sheet, it should update respective incident ticket in servicenow. Please help me with your ideas.

 

 

 

14 REPLIES 14

Hi Varun,

Actually which method are you using in scripted REST API POST or PUT ?

can you post the code which you are using to capture the logs.

Thanks

varunkumar1
Tera Contributor

Hi Harish,

 

I am using POST method for scripted rest API.

 

Below is the code used in it

 

var reqbody = request.body;
var reqdata = reqbody.data;
gs.log("Sheet request data recieved from SS"+ JSON.stringify(reqdata));

var res = request.body.data.challenge;
response.setHeader('Smartsheet-Hook-Response', res);

Hi Varun,

Give the below piece of code and now again try updating the short description in the Smart sheet, Now in logs you should be able to see the Payload sent by the webhook

var parser = new JSONParser();
var parsedData = parser.parse(request.body.dataString);

gs.log(parsedData);

Hope this is Helpful.

Thankyou.

The recommended way to parse JSON data is to use the JavaScript native methods

var obj = JSON.parse(jsonString);

and the reverse to turn it from an object to a string

var str = JSON.stringify(obj);

Additionally, avoid using gs.log and gs.print as they are global only. Your code won't work if someone is writing a spoke for IntegrationHub, for example. gs.debug/gs.info/gs.warn/gs.error work in both global and scope. Use those instead and you'll avoid scoping issues later. 🙂

Thank you @Chuck Tomasi  🙂