Cancel the change task on cancellation of change request
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2022 06:38 PM
Hi All,
I need help to cancel the change task on cancellation of change request. Currently, I am using the below script and it is cancelling the change task only when change task assigned to is NOT Empty. If assigned to on change task remains empty then it do not cancel it.
This BR is on After on changer request table and condition is "active changes to false".
var gr = new GlideRecord('change_task');
gr.addQuery('active', true);
gr.addQuery('change_request.sys_id', current.sys_id);
// I tried this line also gr.addQuery('change_request', current.sys_id); --- didn't help
gr.query();
while(gr.next())
{
gr.state=7; // cancel value
gr.active=false;
gr.update();
gs.addInfoMessage('test2');
}
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2022 06:58 PM
Hi MR,
Please Change this > gr.addQuery('change_request.sys_id', current.sys_id);
with this > gr.addQuery('change_request', current.getUniqueValue());
and try
Mark Correct or Helpful if it helps.
Thanks,
Yousaf
***Mark Correct or Helpful if it helps.***
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2022 07:51 PM
Thanks for your response!
I already tried that but it didn't work
https://community.servicenow.com/community?id=community_question&sys_id=5307943fdb0e4810d82ffb2439961949
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2022 07:04 PM
Hi
I'm wondering why you want to create a new BR as OOTB there is already a BR "Cancel change_tasks" on table "change_request" which does the job for you.
Kind regards
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2022 07:54 PM
Thanks for your response!
would you mind sharing the script over here. Because I didn't find any OOB script with that name "Cancel change_tasks" .