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.

How to get RITM and Task values for each Request?

gokulraj
Giga Expert

Hi All,

The below Request('sc_request") contains two RITM's("sc_req_items") and each RITM will have a Task number("sc_task").

 

I want to display the both RITM number and Task number by using the Request('sc_request") number.

Please share your ideas

find_real_file.png

9 REPLIES 9

rammohanraomadd
Kilo Guru

Hi,

 

Please pull the report on sc task and you will get all the details by dot walk.

 

Regards,

Ram M

Hi ,

I want to get that via script.(e.g If I am passing a request number "REQ0016824" I want to get the RITM number 'RITM0019811' and 'RITM0019810' and also want to achive the task number .

How to achieve this?

 
 
 
620 points - Community Level 2

Hi Gokul,

Please use the below script:

var rarr = [],arr1 = [];

var req = new GlideRecord("sc_req_item");

req.addEncodedQuery("request=" + current.sys_id);

req.query();

while(req.next())

  { 

      arr.push(req.number.toString());

       var task = new GlideRecord("sc_task");

        task.addEncodedQuery("request_item=" + req.sys_id);

        task.query();

        while(task.next())

           {

                arr1.push(task.number.toString());

            } 

   }

gs.print("Request Number : " + current.number);

gs.print("Requested Item Number(s) : " + arr);

gs.print("Task Number (s): " + arr1);

 

 

Regards,
Ram M

Hi,

 

Please find the below script there is a minor error in the above script:

BR To be created on Request table:

 

var arr = [],arr1 = [];

var req = new GlideRecord("sc_req_item");

req.addEncodedQuery("request=" + current.sys_id);

req.query();

while(req.next())

  { 

      arr.push(req.number.toString());

       var task = new GlideRecord("sc_task");

        task.addEncodedQuery("request_item=" + req.sys_id);

        task.query();

        while(task.next())

           {

                arr1.push(task.number.toString());

            } 

   }

gs.print("Request Number : " + current.number);

gs.print("Requested Item Number(s) : " + arr);

gs.print("Task Number (s): " + arr1);

 

 

Regards,

Ram M