Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Report of open RITMs with all closed tasks

Gmaster
Tera Contributor

Hello,

I have a question, how can I create a report (or list it via script) with all open RITMs (State == Open) but where all fulfillment tasks are closed? In other words when there is for example a request which has 5 tasks and all of them are closed but state of the request is Open, then I need that to show in my report.

Aby help much appreciated!

1 ACCEPTED SOLUTION

Mohith Devatte
Tera Sage
Tera Sage

Hello @Gmaster ,

you can try this below script .

I tried this in Background script with the same scenario and it worked

var arr=[];
var gr= new GlideRecord('sc_req_item');
gr.addQuery('state',1);
gr.query();
while(gr.next())
{
var ct = new GlideRecord('sc_task');
ct.addQuery('parent',gr.sys_id);
ct.query();
while(ct.next())
{
if(ct.state==3||ct.state=="3")
{
if(arr.indexOf(gr.number.toString())==-1)
{
arr.push(gr.number.toString());
}
}
}
}
gs.print(arr);

Please mark my answer correct if it helps you

View solution in original post

9 REPLIES 9

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

this link has solution

How to create a report on Active ( open) RITM's where all its tasks are closed

sharing few other links for help

Report on all Open RITMS but all the related sctasks are closed

Need to Build a report on Open RITM when all the associated tasks are closed

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

That could work, thank you!

@Gmaster 

Did you accidentally marked other response as correct?

Your original question was regarding reports and not related to any background/other script.

The 1st link I shared has solution without script.

Would you mind marking appropriate response as correct so that it helps future members.

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Ankur Bawiskar  

Hello,

hope you are doing good ! 

in the question posted it was written as below 

I have a question, how can I create a report (or list it via script) 

Good Day! 

 

 

Hi,

Thanks for asking. I am doing good. Hope you are good and safe !!

I believe the question was about report and I believe it can be achieved without scripting.

Even if script is used it won't work directly. The script should be invoked as well.

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader