- 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-13-2025 12:19 AM - edited 06-13-2025 12:20 AM
- 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:09 PM
// Get the current requested item record
var requestedItem = current;
// Query the sysapproval_approver table to get the approver name
var approverGR = new GlideRecord('sysapproval_approver');
approverGR.addQuery('sysapproval', requestedItem.sys_id); /
approverGR.query();
if (approverGR.next()) {
// Get the approver name
var approverName = approverGR.approver.name;
// Add the approver name to the notification
template.print('Approver Name: ' + approverName);
} else {
template.print('No approver found for this requested item.');
}
@TMKAM take a look this works
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2025 10:28 PM
Dear Rohit,
Thank you for the solution and I have tried but it does not show anything in the email notification.
This what i put in the mail script in the notification.
<mail_script>
// Get the current requested item record
var requestedItem = current;
// Query the sysapproval_approver table to get the approver name
var approverGR = new GlideRecord('sysapproval_approver');
approverGR.addQuery('sysapproval', requestedItem.sys_id); /
approverGR.query();
if (approverGR.next()) {
// Get the approver name
var approverName = approverGR.approver.name;
// Add the approver name to the notification
template.print('Approver Name: ' + approverName);
} else {
template.print('No approver found for this requested item.');
}
</mail_script>