Populate CATCH error in a notification

Facundo Prado
Tera Expert

Hello everyone!
im working in a notifcation, fired by an event. This event is fired by a SScedule job.
In the scheduled Job we have a TRY/CATCH to get the error, so I need to populate the error in the body of the notification, bu I´m still getting this error:

FacundoPrado_0-1713475996499.png


In the Scheduled job I have this try/catch:

FacundoPrado_1-1713476025799.png

 


And this is the notification body:

FacundoPrado_2-1713476104244.png

Any Idea?? Thanks to all.

 

3 REPLIES 3

James Chun
Kilo Patron

Hi @Facundo Prado,

 

Can you share the entire script of the Scheduled Job?

 

Cheers

@James Chun Sure!

 

 

var grReqRoleApprovers = new GlideRecord('x_amspi_access');

grReqRoleApprovers.addEncodedQuery('u_iiq_approval_statusISEMPTY^u_request_role_id.active=true');
grReqRoleApprovers.query();

    while (grReqRoleApprovers.next()) {
        try {
            var reqNum = grReqRoleApprovers.u_request_role_id.u_request_id.number.toString();
            var jsonApprovalPayload = JSON.parse(grReqRoleApprovers.u_iiq_approval_submission_payload);

            // if iiq approval submission payload field has multiple item in it, then push each item to iiqApprovalPayload
            for (var x = 0; x < jsonApprovalPayload.length; x++) {
                iiqApprovalPayload.push(jsonApprovalPayload[x]);
                uniqueNumList.push(reqNum);
            }

        } catch (error) {
            requestDataService.createIntegrationIncident("SN", "N/A", "[My Access Multiple Approval Submissions Queueing Job]: " + error, gs.getUserID());
            gs.error("[My Access Multiple Approval Submissions Queueing Job] SN Request Data Service error " + error);
           
            // Send notification when error is catched
            gs.eventQueue("x_amspi_my_access.request_approval_submi", grReqRoleApprovers, error.message);
        }

    }

 

Hi @Facundo Prado,

 

Thanks for sharing the script.

 

A few things that I noticed in the script:

  • Undeclared variables - iiqApprovalPayload and uniqueNumList
  • Can you verify that the 'u_iiq_approval_submission_payload' field is not empty and it's in JSON string format? The error suggests that it's likely from that.

 

It looks like you are creating an Incident within the 'catch'. If so, why do you need to trigger another email notification as the Incident will generate its own email notification.

Or is this event for a different type of notification?