The CreatorCon Call for Content is officially open! Get started here.

How do I get correlation id through REST API?

Deepika Gangra1
Tera Expert

I want to make it as bi-directional communication of both servicenow instance, but correlation id is not populating..

Thanks in advance

14 REPLIES 14

This is my Br:

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

var r = new sn_ws.RESTMessageV2('example-rest', 'REST');

r.setStringParameterNoEscape("u_number", current.number);
r.setStringParameterNoEscape("u_caller_id", current.caller_id);
r.setStringParameterNoEscape("u_state", current.state);
r.setStringParameterNoEscape("u_category", current.category);
r.setStringParameterNoEscape("u_short_description", current.short_description);
r.setStringParameterNoEscape("u_impact", current.impact);
r.setStringParameterNoEscape("u_urgency", current.urgency);
r.setStringParameterNoEscape("u_priority", current.priority);
r.setStringParameterNoEscape("u_subcategory", current.subcategory);
r.setStringParameterNoEscape("u_assignment_group", current.assignment_group);
r.setStringParameterNoEscape("u_description", current.description);

var response = r.execute();
var responseBody = response.getBody();
var json = responseBody;
var obj = JSON.parse(json);
var foundsysID = obj.result.sys_id;
current.correlation_id = foundsysID;
current.update();


})(current, previous);

 

 

and same fields are mentioned in REST message

Hi,

are you sure you are getting the sys_id in response?

are you parsing it correctly?

I assume your BR should be after insert.

Regards
Ankur

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

I think BR is not correct that's why REST API showing 500 internal server error..

could you help me with scripting part along with correlation id.

 

 

Thanks in advance

Hi,

seems the function is incorrect i.e. REST

it should be POST

Also check you have defined the JSON request in content body or not

Regards
Ankur

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

Naveen87
Tera Guru

Hi All,

 

Seems I have an similar issue.

We r creating e-bonding b/w X & Y company.

X company creates incident & same data flows & created Incident in Y company.

When same incident is created in Y company.

We want to receive the incident number of Y company & store on correlation_id of X company.

Also add 'Y' in response. So we can understand this is coming from Y company.

Ex:- 'Y 1234' (Incident of Y company)(Stored at X company correlation field).