How to find the catalog tasks which are associated with the RITM's?

BalaLalitha Gun
Tera Contributor

Hi,

Using background script, how to find the catalog tasks that are associated with RITM?

Please help me with the request above.

2 REPLIES 2

Harish KM
Kilo Patron
Kilo Patron

You can test this in bg script

var ritm = new GlideRecord('sc_req_item');
ritm.query();
while(ritm.next())
{
var task = new GlideRecord('sc_task');
task.addQuery('request_item',ritm.sys_id);
task.query();
while(task.next())
{
gs.info("RITM"+ritm.number + " Catalog Task "+task.number);
}
}

Regards
Harish

Vamsi Sreenivas
Giga Guru

Hi @BalaLalitha Gundepudi , check the below script.

var query = "active=true^request_item=" + REQUEST-ITEM-SYSID;

var grTask = new GlideRecord('sc_task');
grTask.addEncodedQuery(query);
grTask.query();

while(grTask.next()) {
    gs.info("Associated Task: " + grTask.number);
}

Please try to use active=true/false query based on requirement to avoid slower query times.

Please mark my answer as Helpful / Correct if my response helped you.

Regards,

Vamsi S