- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2022 12:19 PM
I have a script and currently it is not working with GlideAggregate can someone please rectify it:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2022 01:15 PM - edited 11-22-2022 01:16 PM
Here is a script that can do that. Depending on the instance it's going for, amount of RITMs, active tasks and so on it might need to be tweaked. Perhaps even run as a flow instead and so on. I would also probably throw in some more checks in case there aren't any RITMs with state "in progress" or active tasks.
var RITM = new GlideRecord("sc_req_item");
RITM.addEncodedQuery("state=2"); //state is in progress
RITM.query();
var ritmSysids = [];
//Get all RITM sys_ids and put them in a array
while (RITM.next()) {
ritmSysids.push(RITM.getUniqueValue());
}
var checkTasks = new GlideRecord('sc_task');
checkTasks.addQuery('request_item','IN',ritmSysids);
checkTasks.addQuery('active',true);
checkTasks.query();
//Go through active tasks and remove the RITM from the array since it should only contain
//RITM with no active tasks
while(checkTasks.next()){
ritmSysids = ritmSysids.filter(function(item) {
return item != checkTasks.request_item
})
}
gs.info("Sys_ids of RITM with no active tasks: " + ritmSysids)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2022 12:34 PM
Try this
var ritm = new GlideRecord('sc_req_item');
ritm.addEncodedQuery('active=true^RLQUERYsc_task.request_item,=00^active=true^ENDRLQUERY');
ritm.query();
gs.print(ritm.getRowCount());
while(ritm.next()){
gs.print(ritm.number);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2022 12:36 PM
can i not use glide aggregate?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2022 12:42 PM
What are you trying to accomplish exactly? What's the end goal once you have the aggregate count?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2022 12:52 PM
I need the RITM so instead of GlideRecord i wanted to go ahead with GlideAggregate.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2022 12:54 PM - edited 11-22-2022 12:55 PM
The code I provided will give you that and also let you access the RITM details.
var ritm = new GlideRecord('sc_req_item');
ritm.addEncodedQuery('active=true^RLQUERYsc_task.request_item,=00^active=true^ENDRLQUERY');
ritm.query();
gs.print(ritm.getRowCount());
while(ritm.next()){
gs.print(ritm.number);
}