- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 02:57 PM
Hello,
Currently, we have two approvers (John and David) that approve the RITM.
I would like to get the approver first name using email script and use it in RITM notification.
I'm having an issue where both approvers first name are printing on the same line in the email like this:
Could we have one first name print on each email?
Here is the email script. Please help. Thanks
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
var gr = new GlideRecord("sysapproval_approver");
gr.addEncodedQuery("sysapproval=" + current.getUniqueValue() + "^state=requested");
gr.query();
while (gr.next()) {
template.print(gr.approver.first_name.getDisplayValue()); // Print approver first name
}
})(current, template, email, email_action, event);
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 06:17 PM
@Annie10 Please update the script as follows.
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
var gr = new GlideRecord("sysapproval_approver");
gr.addEncodedQuery("sysapproval=" + current.getUniqueValue() + "^state=requested");
gr.query();
while (gr.next()) {
template.print('<p>'+gr.approver.first_name.getDisplayValue()+'</p>'); // Print approver first name
}
})(current, template, email, email_action, event);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 03:26 PM
Hi @Annie10,
Template.print is taking both name in same line because there is no line break.
If you want just one name then replace the while with if , this way flow will consider first record's name only.
if you want both name in different line then use the HTML line break tag with template.print("<br/>");
while (gr.next()) {
template.print(gr.approver.first_name.getDisplayValue()+"<br/>"); // Print approver first name
}
-Thanks,
AshishKMishra
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 06:11 PM
Hello @AshishKM
Do you have an example where I can capture specific variables from a catalog item into the approval notification table? I'm having a hard time figuring out how to do it. Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2023 08:36 AM
Hi @Annie10,
Open the email notification and check how existing variables are configured, you can add the same way other RITM level variable, only thing , if fields are part of Variable section then Email Script can be use to fetch the data from Variable table for that RITM. Let me know if you have any further question or need help. You can share the notification details and required variable details.
-Thanks
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 06:17 PM
@Annie10 Please update the script as follows.
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
var gr = new GlideRecord("sysapproval_approver");
gr.addEncodedQuery("sysapproval=" + current.getUniqueValue() + "^state=requested");
gr.query();
while (gr.next()) {
template.print('<p>'+gr.approver.first_name.getDisplayValue()+'</p>'); // Print approver first name
}
})(current, template, email, email_action, event);