// Process the response returned by the request script
// The 'answer' variable from the request script is passed in here as the 'response' parameter
(function(poll_request, poller, response, params) {
var body = JSON.parse(response);
var conn = poller.getIntegration().getActiveConnection();
var cvars = conn.getVariables();
var poll_helper = new x_snd_eb.PollHelper(poll_request);
if (body.result.length == 0) {
status = 'No Incident found';
poll_request.response_status = status + '\n\n' + JSON.stringify(body, null, 2);
body.result.forEach(function(inc) {
// Set up the payload object
name: 'CreateIncidentInbound',
source_reference: inc.sys_id
caller_id: inc.caller_id,
short_description: inc.short_description,
description: inc.description,
// Set up the options object for message submission
//message_name: 'CreateIncidentInbound',
payload: JSON.stringify(pl)
poll_helper.processInbound(opts);
var inc_time = inc.sys_updated_on;
info.push('Incident : ' + inc.number + ' (' + inc_time + ')');
// Set last update time (if later)
var conn_time = conn.getData('last_update_time', "");
info.push('Conn Time : ' + conn_time);
if (inc_time > conn_time) {
conn.setData('last_update_time', inc_time);
poll_request.response_status = info.join('\n') + '\n\n' + JSON.stringify(body, null, 2);
})(poll_request, poller, response, params);