Accessing multiple catalog task in ATF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-20-2020 11:29 PM
Hi,
In a catalog item that i am testing in ATF the workflow is as such, that it generates multiple catalog tasks(around 15) for a single RITM, i am able to query the sc_task table for all these records, but now i need to access each record and close task for each of them. I tried using the "run server side script",
var grTask = new GlideRecord('sc_task');
grTask.addEncodedQuery('request_item=grTask.number^state=Open');
grTask.query();
while (grTask.next()) {
gs.log('CATNum:'+grTask.number);
grTask.state="Closed Complete";
}
but i do not see the state to be "Closed Complete" for all records. Please help me get a solution.
Regards,
Supritha

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-20-2020 11:37 PM
grTask.addEncodedQuery('request_item=grTask.number^state=Open');
bold text which i have highlighted is not correct , you wont be able to fetch number before the next()
how are you generating the RITM ? i think here you have to store the ritm sys_id in previous step and then use that in next step .

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-21-2020 12:24 AM
Hi,
Use this code:
var requestId = steps('01839145db30ab808812644a4b9619cc').record_id;//Replace the sys id with the step id where you are creating the RITM record.
var grTask = new GlideRecord('sc_task');
grTask.addEncodedQuery('state=Open^request_item='+requestId);
grTask.query();
while (grTask.next()) {
gs.log('CATNum:'+grTask.number);
grTask.state="Closed Complete";
}
Thanks,
Ashutosh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-05-2020 04:17 AM
Please mark answer as correct or helpful as per its impact. If you got your answer.
Thanks,
Ashutosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-21-2020 02:55 AM
Hi,
I am fetching the RITM after ordering the catalog item by querying the sc_req_item table.
Can you please tell me how to actually access multiple catalog tasks or close them all.
Regards,
Supritha