Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

How to trigger a single notification to requestor for the Approval record?

SubhashreeS4370
Tera Contributor

Hi Team,

 

We have a requirement to auto cancel any RITMs, that are not approved within 30days. We are looping through approval records (sysapproval_approver) table, fetching the RITMs, then calling the notification which is sending emails to each approver separately for the same approving record.

 

Current behavior: User is receiving multiple notifications along with approving user.

 

Expected Behavior: Our goal is to notify the user via Additional comments (without sending multiple notifications to the requestor).

 

Flow configuration:

SubhashreeS4370_3-1788360133564.png

 

Notification:

SubhashreeS4370_1-1788360050719.png

 

SubhashreeS4370_2-1788360085263.png

 

Please verify our Flow and let us know how can we trigger a notification to the Requestor (via single notification specific to one ticket) instead of multiple notifications which is happening happening via For-each loop.

 

Thank you in advance!!

 

5 REPLIES 5

Hi @JaganN971616731 ,

You can remove steps 2–5 and use the Set Flow Variables action with script step instead. In the Script step, use the below script as a reference to set the flow variable value:

var ritmIds = {};
var result = [];

var approvalGR = new GlideRecord('sysapproval_approver');
approvalGR.addQuery('state', 'IN', 'approved,rejected,cancelled');
approvalGR.addQuery('source_table', 'sc_req_item');
approvalGR.query();

while (approvalGR.next()) {
    var ritmId = approvalGR.getValue('sysapproval');

    if (ritmId && !ritmIds[ritmId]) {
        ritmIds[ritmId] = true;
        result.push(ritmId);
    }
}

return result.join(',');

 
This will return the unique RITM sys_ids as a comma-separated value.

If you find this useful, please mark it as helpful.

Thanks & Regards,
Harish