- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-12-2025 09:15 PM
Hi All,
I want the approver name from this Approval (sysapproval_approver) table into the current notification Requested Item (sc_req_item) table.
How do I scripted that.
Regards,
TMKam
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-13-2025 12:35 AM
it should work if there are approval records in Requested state in sysapproval_approver table for your RITM
Did you verify that?
You can comment line 7 and see what it prints.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-13-2025 12:42 AM
Hello @TMKAM, you seem to be sending the notification when RITM is cancelled, then approval might be moved out of 'Requested' state. could you please try once more by commenting following line from the code?
approvalGR.addQuery('state', 'requested'); //comment this
Regards,
Nishant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-12-2025 10:03 PM
you can use email script and include that in your notification of RITM table
(function runMailScript(current, template, email, email_action, event) {
// Add your code here
var arr = [];
var approvalGR = new GlideRecord('sysapproval_approver');
approvalGR.addQuery('sysapproval', current.sys_id);
approvalGR.addQuery('state', 'requested');
approvalGR.query();
while (approvalGR.next()) {
arr.push(approvalGR.approver.getDisplayValue());
}
template.print('Approvers for RITM are:' + arr.toString());
})(current, template, email, email_action, event);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-12-2025 10:26 PM
Dear Ankur,
Thank you for the solution and I have tries but i cant show the approver anme and here are the mail scripts i have inserted in the email notification.
<mail_script>
// Add your code here
var arr = [];
var approvalGR = new GlideRecord('sysapproval_approver');
approvalGR.addQuery('sysapproval', current.sys_id);
approvalGR.addQuery('state', 'requested');
approvalGR.query();
while (approvalGR.next()) {
arr.push(approvalGR.approver.getDisplayValue());
}
template.print('Approvers for RITM are:' + arr.toString());
</mail_script>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-12-2025 11:11 PM
please share screenshots of where are you writing this?
is this in workflow notification activity?
are there approval records for this RITM in requested state?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-12-2025 11:50 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-13-2025 12:02 AM
you need to study how notifications work and how to include email script in it
once you create email script you need to include like this in Message HTML
${mail_script:mailScriptName}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader