Get the catalog tasks of an RITM

ramya0905
Kilo Expert

Hi All,

Could you please help me to get all the task numbers generated under an RITM and check for a particualar assignment group for that task..

RITMxxxx

-TASKxxx1

-TASKxxx2

-TASKxxx3

How do i get this with the RITM's sys_id..

1 ACCEPTED SOLUTION

Hi Ramya,



Add new activity to your workflow - "Run Script" after finishing the the Task Creation.


And in the "Script" part of run script add the code as:


function getRec()


{


  var gr = new GlideRecord('sc_task');


  gr.addQuery('request_item',current.sys_id);


  gr.query();


  while(gr.next())


  {



    gs.log(gr.number);


  }


}



you will get all the tasks related to current RITM.



Thanks,


Ganesh


View solution in original post

9 REPLIES 9

Hi Ramya,



You can use the "Run Script" utility after the second task in the workflow.


Hi Ramya,



Add new activity to your workflow - "Run Script" after finishing the the Task Creation.


And in the "Script" part of run script add the code as:


function getRec()


{


  var gr = new GlideRecord('sc_task');


  gr.addQuery('request_item',current.sys_id);


  gr.query();


  while(gr.next())


  {



    gs.log(gr.number);


  }


}



you will get all the tasks related to current RITM.



Thanks,


Ganesh


Please mark the discussion as Answered , if you feel so..


Hello - This is a question out side of this thread... In your screen shot I see the error of basic authentication failed where you able to check this error or any fix ??

Hello - I had quick question on the same note the above logic helps you retrieve all the tasks under the RITM but in the same logic how can we drill down to one Task with certain conditions. I know I can add another addQuery to write the short description but I dont want my code to have some text which can be modified from the front end and hampers the workflow...

 

var gr_tsk = new GlideRecord("sc_task");
gr_tsk.addQuery('request_item', current.sys_id);


gr_tsk.addQuery('short_description', 'Task for IAM'); // Out of 10 or 100 tasks the RITM has I can identify the one i  want by using short description but I want to know if there is a better way to identify each task under the RITM uniquely


gr_tsk.query();
if(gr_tsk.next())
{
return yes;
}
return no;