warren_chan
ServiceNow Employee

I believe that the "outputs" array isn't specifically declared, and rather, whatever is returned is understood as the output. Try this:

 

(function execute(inputs) {

    var incNumber = inputs.incident_number;
    var outputs = '';

    if (!incNumber) {
        outputs = "Error: Incident number not provided";
        return;
    }

    var gr = new GlideRecordSecure("incident");
    gr.addQuery("number", incNumber);
    gr.query();

    if (gr.next()) {
        outputs += "Incident Found";
        outputs += "Short description: " + gr.short_description.toString();
        outputs += "State: " + gr.getDisplayValue("state");
        outputs += "Caller: " + gr.getDisplayValue("caller_id");
    } else {
        outputs = "Incident Not Found";
    }

    return outputs;

})(inputs);

 

View solution in original post