- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2026 12:48 AM - edited 02-13-2026 12:48 AM
Hi team,
Report on RITM where one task (Short Description starts with X) is Closed Complete and another task (Short Description starts with Y) is not Closed Complete
I have a requirement to create a report where:
A RITM has one Catalog Task whose Short Description STARTS WITH "Core" and is Closed Complete
And another Catalog Task whose Short Description STARTS WITH "Approval" and is NOT Closed Complete
Both tasks belong to the same RITM.
So far, I have created a Database View and joined:
sc_req_item
sc_task
However, I’m not sure how to correctly handle the Short Description condition.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2026 02:50 AM
1) create classless script include like this
function getRecords() {
var ritmSysIds = []; // Array to store matching RITM sys_ids
var ritm = new GlideRecord('sc_req_item');
ritm.query(); // Add filters: ritm.addQuery('active', true);
while (ritm.next()) {
var hasCoreClosed = false;
var hasApprovalOpen = false;
var task = new GlideRecord('sc_task');
task.addQuery('request_item', ritm.sys_id);
task.query();
while (task.next()) {
var desc = task.short_description.toString();
if (desc.startsWith('Core') && task.state == 7) {
hasCoreClosed = true;
}
if (desc.startsWith('Approval') && task.state != 7) {
hasApprovalOpen = true;
}
}
if (hasCoreClosed && hasApprovalOpen) {
ritmSysIds.push(ritm.sys_id.toString());
}
}
return ritmSysIds.toString();
}
2) then call like this Sys ID [IS ONE OF] javascript: getRecords();
💡 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 || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2026 07:27 AM
it will if your RITM table is huge and it has lot of sc_tasks under those RITMs
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
