Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

How to get the catalog task number associated with a requested item

suprakash
Giga Expert

for my requested item a catalog task is generated . I want to get the the task number which is present in in related list in my requested item form.How can i get it using background script

7 REPLIES 7

kalyan778
Mega Guru

Hi Dutta,



Try below code for getting the single   task number for single request.



var gr=new GlideRecord('sc_task');


gr.addQuery('request_item','RITM sys_id');//provide the ritm sys_id


gr.query();


if(gr.next())


{


gs.log("TAsk num"+gr.number);


}



Let me know if you have any queries.



Thanks


There is a typo on @kalyan script.



Here is the updated one



var gr=new GlideRecord('sc_task');


gr.addQuery('request_item','RITM sys_id');//provide the ritm sys_id


gr.query();



while(gr.next()) // if you have multiple tasks associated with RITM


{


gs.log("TAsk num"+gr.number);


}


Thanks Kalyan ,


In the same way i did also.


I was just trying that if can we take the the object of sc_req_item and get the related list details


you can get the full sc_req_item object like so...



var sid = (whatever the sys_id of the requested item is)


var bubotuber = new GlideRecord('sc_req_item');


bubotuber.get(sid);   //bubotuber is now the full sc_req_item object



... but to get the related sc_tasks, you also have to do a query like those shown above.