List all approvers in an email notification

Alex Saager1
Tera Contributor

Hi Community,

 

I've designed a flow for approval reminders that automatically closes a request if no action is taken. However, I'm encountering a challenge with the email notification: I can only display one approver, whereas I’d like to include all individuals the approval request was sent to.


Is there a straightforward way to list all approvers in the notification email?

 

AlexSaager1_0-1756811806948.png

 

9 REPLIES 9

Rafael Batistot
Kilo Patron

Hi @Alex Saager1 

 


May you use a Notification Email Script

Add an Email Script (under System Notification > Email > Notification Email Scripts) and call it in your notification body. For example:

 

// Example: Get all approvers for the RITM
(function() {
var approvers = [];
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval', current.sys_id); // current = RITM or Requested Item
gr.addQuery('state', 'requested'); // only pending approvers
gr.query();
while (gr.next()) {
approvers.push(gr.approver.getDisplayValue());
}
template.print(approvers.join(', '));
})();

Then, in your notification, you can insert:

 

${mail_script:AllApproversList}

If you found this response helpful, please mark it as Helpful. If it fully answered your question, consider marking it as Correct. Doing so helps other users find accurate and useful information more easily.

Bhuvan
Giga Patron

@Alex Saager1 

 

Create a notification email script and use it in flow action.

 

Below is a sample,

    (function runMailScript(current, template, email, email_action, event) {
        var approversArray = [];
        var gr = new GlideRecord('sysapproval_approver');
        gr.addQuery('sysapproval', current.sys_id); 
        gr.query();
        while (gr.next()) {
            approversArray.push(gr.approver.getDisplayValue()); 
        }
        if (approversArray.length > 0) {
            template.print("Approvers: " + approversArray.join(", ")); 
        } else {
            template.print("No active approvers found.");
        }
    })(current, template, email, email_action, event);

If this helped to answer your query, please mark it helpful & accept the solution.

 

Thanks,

Bhuvan

@Alex Saager1 

 

Below is a sample of doing the same function via Flow variables,

 

https://www.servicenow.com/community/workflow-automation-blogs/scripted-approvals-in-flow-designer-w...

 

If this helped to answer your query, please mark it helpful & accept the solution.

 

Thanks,

Bhuvan

@Alex Saager1 

 

Thanks for marking the post as helpful.

 

If this helped to answer your query, please accept the solution.

 

Thanks,

Bhuvan