When a change request is cancelled "Pending" change tasks have to be put on state "Cancelled"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2023 12:57 AM
I have a requirement When a change request is cancelled all pending change tasks have to be put on state "cancelled" as well. Currently they remain on "pending"
I tried this script in the workflow
And add this here
But it is not working and I also tried UI policy, scripts but it is not reflecting on change task, please send any suggestions on how to accomplish this.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2023 04:01 AM
I guess this workflow is running on the change_request table?
If so, you'll have to lookup the tasks before you can close them. You are currently only updating the state of the change itself.
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2023 04:10 AM
Yes this workflow is running on the change_request table.
But what will be the solution I also updated the change_task table, tried UI Policy, scripting but nothing works.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2023 04:17 AM
@Tuhina Sharma Create following business rule on Change Request table.
Here is the script for the BR.
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var gr = new GlideRecord('change_task');
gr.addQuery('change_request', current.sys_id);
gr.addQuery('state','-5');//Pending state filter
gr.query();
if (gr.next()) {
gr.setValue('state','4');//Set to cancelled
gr.update();
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2023 04:20 AM
Or use the script @Sandeep Rajput provided in your workflow. Should work exactly the same (excluding the first and last line)
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.