- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2019 12:38 PM
Hello,
I need to create a business rule (enlighten me if there's a better approach) in order to change the state of all tasks associated to a Change record to a Cancelled State and inactive when the related change record's Approval is Cancelled.
At the moment, I have a business rule set on the Change Request table to run when approval changes to Cancelled.
When: After; Insert and Update selected.
The script I have on the Advanced tab is as follows:
cancelTasks();
function cancelTasks() {
if (current.sys_id == '')
return;
var tasks = new GlideRecord('change_task');
tasks.addQuery('parent', current.sys_id);
tasks.query();
while (tasks.next()) {
if (tasks.active == true) {
tasks.state = -4;
tasks.active = false;
tasks.update();
}
}
}
Not certain what I'm missing, any help would help.
Regards,
Denis
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2019 06:00 AM
I was able to fix this.
I was running my Business Rule on the Change Request table, I had to change my rule in order for it to run on the sysapproval_approver table.
That change in addition to the script below allowed me to perform was I was looking for.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2019 12:44 PM
Please update the below line to
tasks.addQuery('change_request', current.sys_id);
Also make sure that approval field on change request is setting to cancelled
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2019 06:00 AM