- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2024 02:55 AM
Hello Developers,
We are doing E-bonding b/w X & Y companies.
X company is passing Incident data & it's flowing as expected & creating ticket on Y company Incident table with information passed.
I want to receive the ticket number created on Y company on correlation ID field of X company, to confirm that ticket is created.
I have done below stuff but not receiving it. Not sure what is missed.
Please guide me
ebondIncidentUpdate: function() {
//var pathParams = request.pathParams;
//var table = pathParams.tableName;
var requestBody = request.body;
var requestData = requestBody.data;
if (requestData.u_partner_ticket_id == undefined || requestData.u_partner_ticket_id == '')
{
response.setError(new sn_ws_err.BadRequestError('Correlation ID is missing'));
return;
}
if (requestData.number == undefined || requestData.number == '')
{
response.setError(new sn_ws_err.BadRequestError('Number is missing'));
return;
}
var gr = new GlideRecord('incident');
gr.addQuery('number', requestData.number);
gr.query();
if (gr.next()) {
gr.correlation_id = requestData.u_partner_ticket_id;
gr.update();
} else {
response.setError(new sn_ws_err.BadRequestError('Incident not found'));
return;
}
// start building response object
response.setStatus(200);
response.setContentType('application/json');
var body = {
status: 'ok',
requesterId: gr.number,
providerId: gr.correlation_id,
sys_id: gr.getUniqueValue()
};
response.setBody(body);
var jsonObj = JSON.parse(responseBody)
var ticketid = jsonObj.result.u_partner_ticket_id;
},
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2024 05:29 AM
Please ignore.
I have found the solution.
I had to modify the BR.
var response = r.execute();
var responseBody = response.getBody();
gs.info("responseBody Wipro" + responseBody);
var jsonObj = JSON.parse(responseBody)
var ticketid = jsonObj.result.u_partner_ticket_id;
current.correlation_id = ticketid;
var httpStatus = response.getStatusCode();
} catch (ex) {
var message = ex.message;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2024 05:29 AM
Please ignore.
I have found the solution.
I had to modify the BR.
var response = r.execute();
var responseBody = response.getBody();
gs.info("responseBody Wipro" + responseBody);
var jsonObj = JSON.parse(responseBody)
var ticketid = jsonObj.result.u_partner_ticket_id;
current.correlation_id = ticketid;
var httpStatus = response.getStatusCode();
} catch (ex) {
var message = ex.message;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2024 05:35 AM
Bingo @Naveen87 !
Yes, exactly. Here you've parsed the response body and updated from it.
Can you mark my answer helpful and correct.
Regards,
Amit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2024 06:00 AM
Sure. Guide me on this & I will mark it.
I want to check, If correlation ID is already set or empty.
If correlation id contains 'euwbond'. Then we are fine.
If it's something else then we want to show an error msg.
Please guide me with line of code to written on BR.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2024 06:19 AM
I used this but something is wrong.
no correlation id was created.
if (correlationId.indexOf("euwbond:") !== -1) {
if (correlationId === "euwbond:") {
// Correlation ID is fine
gs.addInfoMessage("Correlation ID is already set.");
} else {
// A new ID came in through another
gs.addErrorMessage("A new ID came in through another.");
}
} else {
// Correlation ID does not contain EUW
gs.addErrorMessage("Correlation ID does not contain EUW.");
}
Whole BR.
(function executeRule(current, previous /*null when async*/ ) {
try {
var r = new sn_ws.RESTMessageV2('global.EUW Ebonding', 'POST Incident');
r.setStringParameterNoEscape('u_customer_ticket_id', current.number);
r.setStringParameterNoEscape('u_shr_priority', current.priority);
r.setStringParameterNoEscape('u_shr_assignment_group', current.getDisplayValue('assignment_group'));
var response = r.execute();
var responseBody = response.getBody();
gs.info("responseBody Wipro" + responseBody);
// if (correlationId.indexOf("euwbond:") !== -1) {
// if (correlationId === "euwbond:") {
// // Correlation ID is fine
// gs.addInfoMessage("Correlation ID is already set.");
// } else {
// // A new ID came in through another
// gs.addErrorMessage("A new ID came in through another.");
// }
// } else {
// // Correlation ID does not contain EUW
// gs.addErrorMessage("Correlation ID does not contain EUW.");
// }
var jsonObj = JSON.parse(responseBody)
var ticketid = jsonObj.result.u_partner_ticket_id; current.correlation_id = 'euwbond:' + ticketid;
var httpStatus = response.getStatusCode();
}
catch (ex) {
var message = ex.message;
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2024 07:24 AM
Hi @Naveen87 ,
Your code looks mostly correct, but there are a couple of adjustments needed.
(function executeRule(current, previous /*null when async*/ ) {
try {
var r = new sn_ws.RESTMessageV2('global.EUW Ebonding', 'POST Incident');
r.setStringParameterNoEscape('u_customer_ticket_id', current.number);
r.setStringParameterNoEscape('u_shr_priority', current.priority);
r.setStringParameterNoEscape('u_shr_assignment_group', current.getDisplayValue('assignment_group'));
var response = r.execute();
var responseBody = response.getBody();
gs.info("responseBody Wipro" + responseBody);
var jsonObj = JSON.parse(responseBody);
var ticketid = jsonObj.result.u_partner_ticket_id;
current.correlation_id = 'euwbond:' + ticketid;
var httpStatus = response.getStatusCode();
} catch (ex) {
var message = ex.message;
}
})(current, previous);