RITM and Request must be same as Catalog Task state, When state changes

abdul rajak
Kilo Contributor

Hi All,

I want to keep RITM and Request states same as Catalog Task(SC TASK) state for particular catalog task's when state changes.

ex: If Catalog Task state changes to 'working in progress' then RITM and Request state also should be same in 'Working in progess'.

Please help me.

13 REPLIES 13

Chetan Mahajan
Kilo Sage
Kilo Sage

Hi Abdul,

                     Create After Update BR on sc_task table where condition is state changes to 'Work in Progress' and write below code

(function executeRule(current, previous /*null when async*/ ) {

var getritm=new GlideRecord('sc_req_item');
getritm.addQuery('sys_id',current.request_item);
getritm.query();
if(getritm.next())
{
getritm.state=current.state;
getritm.update();
}

var getreq=new GlideRecord('sc_request');
getreq.addQuery('sys_id',current.request);
getreq.query();
if(getreq.next())
{
getreq.state=current.state;
getreq.update();
}

})(current, previous);

 

Kindly mark correct and helpful if applicable

Hi Chetan,

 

Yes, it is working as expected but when ever I changes state in SC TASK, it is reflecting in RITM as well but not reflecting same in REQ(request).

 

RITM image:

find_real_file.png

 

 

Request image:

 

find_real_file.png

 

 

 

Thank you.

 

Regards,

Rajak

Aman Kumar S
Kilo Patron

Hey,

Few precautions here, make sure state transition doesn't happen on workflow level:

Write up a Insert/Update After Business rule, and condition as State changes on Catalog task table, use belwo script:

var requestedItem = current.request_item.getRefRecord();
requestedItem.setValue("state", current.setValue("state"));
requestedItem.update();
var request = current.request_item.request.getRefRecord();
request.setValue("state", current.setValue("state"));
request.update();
Best Regards
Aman Kumar

Hi Aman,

 

I tried with your script. no, it is not working for me.