Accessing multiple catalog task in ATF

Supritha3
Tera Contributor

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 

15 REPLIES 15

Harsh Vardhan
Giga Patron

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 . 

Ashutosh Munot1
Kilo Patron
Kilo Patron

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

Please mark answer as correct or helpful as per its impact. If you got your answer.

Thanks,
Ashutosh

Supritha3
Tera Contributor

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