How do i get the "corelation id" using integration rest api

KallaSpandana
Tera Contributor

Hi,

 

I need to get the  corelation id between two instances. Can anyone please help on this ? @Ankur Bawiskar 

 

Thanks,

Spandana.

1 ACCEPTED SOLUTION

@Ankur Bawiskar after testing it in the instance B , I am getting this error. Please refer to the attached snip for reference

View solution in original post

15 REPLIES 15

@KallaSpandana 

you need to write the logic in the instance B i.e. the place from where this scripted REST API is called.

You are already passing the INC number, use that and set in the instance B INC correlation_id field

which script from instance B is invoking this API? is that a business rule?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar the above script is written in instance B also. And this was the business rule in instance B 

 var request = new sn_ws.RESTMessageV2('testing_demo_A', 'incident insert');
    request.setStringParameterNoEscape('u_caller', current.caller_id);
    request.setStringParameter('u_short_description', current.short_description);
    request.setStringParameterNoEscape('u_description', current.description);
    request.setStringParameterNoEscape('u_assignment_group', current.assignment_group);
    //request.setRequestHeader
    var response = request.execute();
    var responseBody = response.getBody();
    var statuscode = response.getStatusCode();
    var errorMsg = response.getErrorMessage();

    gs.info("responseBody" + responseBody);

@KallaSpandana 

then something like this if this is after insert business rule

 var request = new sn_ws.RESTMessageV2('testing_demo_A', 'incident insert');
 request.setStringParameterNoEscape('u_caller', current.caller_id);
 request.setStringParameter('u_short_description', current.short_description);
 request.setStringParameterNoEscape('u_description', current.description);
 request.setStringParameterNoEscape('u_assignment_group', current.assignment_group);
 //request.setRequestHeader
 var response = request.execute();
 var responseBody = response.getBody();
 var statuscode = response.getStatusCode();
 var errorMsg = response.getErrorMessage();
var parsedData = JSON.parse(responseBody);

current.correlation_id = parsedData.incidentnumber;
current.update();

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar do we need to update the same in instance A also ?

@KallaSpandana 

yes correct.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader