How to create report of RITMs with No approval in association with workflow?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
RITM with No Approval
This scenario is valid if there is workflow being used and for some reason the approval stage has no approval in it.
1. Create a script include named 'RITMnoApproval' with client callable and sandbox enabled as ticked.
Code:
var RITMnoApprover = Class.create();
RITMnoApprover.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getRITMnoApprover: function() {
var ritmList = []; // Array to hold the sys_ids of RITMs that DO have approval records
var noritmList = []; // Array to hold the sys_ids of RITMs that DO NOT have approval records
// 1. Query the Approval table for all RITM-related approval records
var grApp = new GlideRecord('sysapproval_approver');
grApp.addQuery('source_table', 'sc_req_item');
// Add any state filtering if needed, e.g., only those currently active/pending
// grApp.addQuery('state', 'requested');
grApp.query();
while (grApp.next()) {
// Collect the sys_id of the RITM that has an approval record
ritmList.push(grApp.sysapproval.toString());
}
// 2. Query the RITM table
var grRITM = new GlideRecord('sc_req_item');
// Filter for RITMs that should be awaiting approval
grRITM.addQuery('approval', 'requested'); // or 'in progress', depending on your workflow
// EXCLUDE RITMs found in the approval table list
if (ritmList.length > 0) {
grRITM.addQuery('sys_id', 'NOT IN', ritmList.join(','));
}
grRITM.query();
//gs.print('RITMs with no approvers:');
while (grRITM.next()) {
noritmList.push(grRITM.sys_id.toString()); // Print the RITM number
}
return noritmList;
},
type: 'RITMnoApprover'
});
2. Create a report with table as 'sc_req_item', list view and give filter condition as
sys_id 'is one of' javascript: new global.RITMnoApprover().getRITMnoApprover()
Kindly mark this article as helpful or drop doubts in comments, if any.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
