How to check if current ritm has 1 sctask or many?

Sri56
Tera Contributor

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

8 REPLIES 8

Sai Kumar B
Mega Sage
Mega Sage

Hi Author,

1.) Go to the RITM table

2.) Locate the specific RITM record

3.) In related lists you can check associated sc_tasks

find_real_file.png

 

Hi Sai,

I need to check in script 🙂

Please help!

 

Thanks,

Sri

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
}
}
   
Please hit like and mark my response as correct if that helps
Regards,
Musab

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
}