How to check if RITM has one sctask or many?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2022 12:58 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:33 AM
Hi Author,
1.) Go to the RITM table
2.) Locate the specific RITM record
3.) In related lists you can check associated sc_tasks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2022 01:39 AM
Hi,
You need to write script in business rule to check that.
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
}
Mark as correct and helpful if it solved your query.
Regards,
Sumanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2022 05:22 AM
Feel free to reach out if you have further questions or else you can mark an answer as correct and helpful to close the thread so that it benefits future visitors also.
Regards,
Sumanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-02-2022 01:12 AM
Hi Sumanth,
I am using above code on my business rule, where i have created a after update on sc_task table.
Condition: state changes from pending
and state changes to work in progress
my code:
(function executeRule(current, previous /*null when async*/ ) {
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('sys_id', current.request_item);
ritm.query();
var count = ritm.getRowCount();
if (count == 1) {
ritm.setValue('state', 2);
ritm.update();
}})(current, previous);
This is updating the status as expected,
But its creating new empty RITM record as below:
Please help me on how to fix this!
Thanks,
Sri