Generating report from scripting which lists RITM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi Experts,
I am stuck at a point where the customer is asking for report of RITMs which I was able to list after writing script for it.
Please give me idea how to generate report from script which lists down RITM.
- Labels:
-
Reporting

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
What kind of script are you writing?
You can use the out of box reports module to generation the report. If you share the logic used it script I can suggest if it is possible using the ootb reports
Palani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
var ritmList = []; // Array to hold the sys_ids of RITMs that DO 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()) {
gs.print(grRITM.number); // Print the RITM number
}
The requirement is to list down all RITM which have no approvals and send it via report.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
var ritmList = []; // Array to hold the sys_ids of RITMs that DO 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()) {
gs.print(grRITM.number); // Print the RITM number
}
This code lists down all RITM that have no approvers, please let me know if it is possible to publish report for this...
Thanks,
Ataur.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
what's your actual business requirement?
💡 If my response helped, please mark it as correct ✔️ and close the thread 🔒 — this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader