// 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);
// Nothing to do if no results were returned
if ( body.result.length == 0 ) {
poll_request.response_status = 'No Incidents returned\n\n' + JSON.stringify(body,null,2);
"sys_id": "0ecc4865db734010c3ebde82ca961960",
"correlation_id": "INC0010345",
// Establish the environment
var integration = poller.getIntegration();
var conn = integration.getActiveConnection();
var cvars = conn.getVariables();
body.result.forEach(function(inc){
// Set up a Poll to retrieve an Incident (returns PollRequest object)
var pr = x_snd_eb.Poller.execute( cvars.incident_poller, {
info.push('Incident: ' + inc.number + ' - PollRequest: ' + pr.getValue('number'));
poll_request.response_status = info.join('\n') + '\n\n' + JSON.stringify(body,null,2);
})(poll_request, poller, response, params);