How to check if current ritm has 1 sctask or many?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2022 01:05 AM
Hi Team,
I have one biz rule on sc_task.
where, after update and state changes from pending to WIP, i need to check if current.request_item has multiple sctask, i need not to update.
In other way, if ritm has multiple sctask, i need to update the ritm status to WIP(state sync).
Can someone please help me know whether current ritm has 1 or more sc_task?
Thanks.
Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2022 01:32 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2022 01:34 AM
Hi Sai,
I need to check in script 🙂
Please help!
Thanks,
Sri

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2022 01:38 AM
Hello,
Take this script and tweak logic accordingly. Don't use getRowcount as it might affect performance
var gr = new GlideAggregate('sc_task');
gr.addQuery("request_item", current.request_item);
gr.addAggregate('COUNT');
gr.query();
if(gr.next())
{
if(ga.getAggregate('COUNT') > 1)
{
current.state = add value;
}
else
{
do something
}
}
Regards,
Musab

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2022 01:40 AM
Looks like this is duplicate question.
Answer already posted there.
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('request_item', current.request_item);
ritm.query();
var count = ritm.getRowCount();
gs.log(count);
if(count == 1)
{
//do here if ritm has only one sc task
}
else if(count > 1)
{
//do here if ritm has only more than one sc task
}