Update the Incident Work Notes that Change has been Rejected

Sakshi Lambat
Tera Contributor

When the Change Request moves from Authorize to Scheduled state then Approval gets generated, if we reject the approval then the incident work notes must get updated that the 'Change has been rejected for the incident'. Please help me to figure out this

1 ACCEPTED SOLUTION

There is definitely an extra } there, try this:

 

(function executeRule(current, previous /* previous state */) {

        var incidentGR = new GlideRecord('incident');
        if (incidentGR.get('rfc', current.sys_id)) {
            // Update incident work notes
            incidentGR.work_notes = 'Change request has been rejected: ' + current.number;
            // Here you can also add a status change maybe
            incidentGR.update();
        }

})(current, previous);

View solution in original post

16 REPLIES 16

Hi,

SakshiLambat_0-1701962238567.png

Getting this error...and if i remove parenthesis then the work note is appearing multiple times in a loop

There is definitely an extra } there, try this:

 

(function executeRule(current, previous /* previous state */) {

        var incidentGR = new GlideRecord('incident');
        if (incidentGR.get('rfc', current.sys_id)) {
            // Update incident work notes
            incidentGR.work_notes = 'Change request has been rejected: ' + current.number;
            // Here you can also add a status change maybe
            incidentGR.update();
        }

})(current, previous);

Again the worknotes are getting multiple times

Can you share more screenshots? From your condition and the work notes being inserted. I'm afraid that there are other rules overlaping.

Screenshot 2023-12-07 at 9.32.30 PM.pngScreenshot 2023-12-07 at 9.32.51 PM.pngScreenshot 2023-12-07 at 9.33.12 PM.png