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

Ankur Bawiskar
Tera Patron
Tera Patron

@KallaSpandana 

Please explain your business requirement in detail. I have explained what that field can do or help with.

when you connect 2 ServiceNow instances using bi-directional integration then usually correlation_id field on task table is used to store the ticket number present in the other instance.

This helps for pushing any updates to the target instance and the updates are pushed to the correct ticket in target instance.

correlation_id can be used to store INC number or INC sysId available in the target instance

Example: From Instance A you are creating INC and the same INC is to be created in instance B, when you consume the endpoint of Instance B, you can store the newly created INC number or INC sysId in the instance A whenever you get API response

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 Here the requirement is we are using bi directional integration , From instance A I created an incident so it was created in instance B. The incident which I created in instance B was also got created in instance A. So, now we want the correlation id should also populate whenever the incident gets creates in instance A or instance B also How to achieve this ?

 

Thanks,

Spandana.

@KallaSpandana 

in that case whenever you are consuming instance B endpoint, you will get response

Parse that response, get the INC number or INC sysId and store that in INC of instance A

what script did you try so far? share that and what debugging did you do?

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 here is the scripted rest api in instance A :

var responseBody = {};
    var event = request.body.data;
    gs.info('spandanav kalla'+ event);
    var inc = new GlideRecord('incident');
    inc.initialize();
    inc.caller_id = event.caller_id;
    inc.short_description = event.short_description;
    inc.description = event.description;
    inc.assignment_group = event.assignment_group;
    inc.insert();
    responseBody.message = "Incident created.";
    responseBody.incidentnumber = inc.number;
    response.setBody(responseBody);