Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-27-2025 01:57 PM
Can anyone assist me with why this query does not work?
var requestID = '6f6416e5476c6610872475f4116d43d8';
//Find all approvals where the parent is the same.
var approvalQuery = new GlideRecord('sysapproval_approver');
approvalQuery.addQuery('sysapproval.parent', requestID);
approvalQuery.query();
while(approvalQuery.next())
{
gs.info(approvalQuery.sysapproval.sys_id);
}
I am looking to query the sysapproval_approver table to find all records where the "Approval For's" parent is the same.
Specifically, I am looking to group together the RITM approval records based on the parent request.
For further context, I am being tasked to consolidate individual RITM approver emails into one email.
My thinking is as follows.
Query sysapproval_approver table and find all records where the approver is the same, and where the parent request is the same.
If there is only one record, trigger event to send "single approval email".
If more than one record trigger event to send "multiple approvals email"
I am still debating if this is even possible within a business rule / script include. Since each record being inserted into the sysapproval_approver table will generate an instance of the rule, which wouldn't be a solution for this problem.
I am thinking that I might have to create a scheduled job to accomplish this, and then mark each record the scheduled job targets, so I don't re-run the approval process again, the next time the job triggers.
Any advice / tips would be most appreciated. Thank you in advance.
Solved! Go to Solution.
1 ACCEPTED SOLUTION
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2025 07:24 AM
ServiceNow support was able to figure out a solution:
var requestID = '6f6416e5476c6610872475f4116d43d8';
var approvalQuery = new GlideRecord('sysapproval_approver');
approvalQuery.addQuery('sysapproval.task.request', requestID);
approvalQuery.query();
while(approvalQuery.next())
{
gs.info(approvalQuery.sysapproval.number);
}
6 REPLIES 6
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2025 06:08 AM
For added confusion, I am not able to query the list for the RITM's parent approval record using the "Approval For" field either.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2025 07:24 AM
ServiceNow support was able to figure out a solution:
var requestID = '6f6416e5476c6610872475f4116d43d8';
var approvalQuery = new GlideRecord('sysapproval_approver');
approvalQuery.addQuery('sysapproval.task.request', requestID);
approvalQuery.query();
while(approvalQuery.next())
{
gs.info(approvalQuery.sysapproval.number);
}