- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2020 11:10 AM
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?
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();
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-29-2020 04:16 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2020 11:17 AM
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();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2020 11:33 AM
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?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2020 11:44 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-28-2020 12:08 PM
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.