When RITM state is Set to Close Complete/Incomplete/skipped related catalog task should also close Complete/Imcomplete/skipped.

Niharika20
Tera Expert

We have requirement, when we RITM state changes to Close Complete/Incomplete/skipped the its related service catalog task should also close. For that i wrote the below business rule but is is not working, can someone please assist?

find_real_file.png


var gr = new GlideRecord('sc_req_item');
gr.addQuery('request_item',current.request_item);
gr.addQuery('active',true);
gr.query();
if(!gr.next()) {

var sc_task = new GlideRecord('sc_task');
sc_task.addQuery('sys_id',current.request_item);
sc_task.query();
if(sc_task.next())
{
//update the fiel of sc_task
sc_task.update();
}

1 ACCEPTED SOLUTION

Thanks Alok, Business rule is working but when i tried cancelling the RITM from portal it is not working. As you said may be i should include script in widget itself.

View solution in original post

12 REPLIES 12

Yash Agrawal1
Tera Guru

Hello Niharika,

Instead of business rule,you can try the workflow RUNSCRIPT activity,which alows you to execute the piece of code.

var gr = new GlideRecord('sc_req_item');
gr.addQuery('request_item',current.request_item);
gr.addActiveQuery();
gr.query();
if(!gr.next()) 
{

var grtask = new GlideRecord('sc_task');
grtask.addQuery('sys_id',current.request.request_item);
grtask.query();
if(grtask.next())
{
  grtask.state=3;// assuming 3 as close state number,please put correct state value
  grtask.update();
}

Thank Yash, problem here is i've created cancel button service portal so whenever i am canceling the RITM from service portal only RITM is getting closed so i want to close the relevant catalog also closed whenever i am cancelling a request from service portal.

That's why i tried writing this business rule but it isn't working as expected. do you have any suggestions for that?

Hello Niharika,

Yeah sure ,i will like yo help you,

Please tell on that close button you want to close the task of that ritm or the request .

Please keep posted,so that. i can help you

Regards

Yash Agawal

Thank you Yash, i want to close all the related tickets to the RITM.. like now if i clicked close only RITM is getting closed but SCTASK related to it is still showing Open state. i want all RITM, SCtask and Req to close. hope you understood my point.