- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2018 11:25 PM
Hi, I'm struggling to compile a Business Rule script for a scenario I need. When I have multiple change tasks, if I close/cancel one of them I need to then auto close all of the others within the change request as well, with a specific reason code that is showing in a drop down list of a custom field.
So for example, I have 4 change tasks called:
Implement change
Inform CAB
Restrict capabilities
Control output
If within the 'Implement Change' task I close or cancel it, it should auto close the other three and select a closure code from a drop down field list that Ive created as a custom field.
I know how to auto close tasks if the change request is cancelled using a BR with a glide record and referring to the state record reference, so I presume its something similar?
I'd like to know how to set this please...
Solved! Go to Solution.
- Labels:
-
Change Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-18-2018 05:15 PM
Hello Simon,
To work on this, please write a Business Rule with Before and Update checked, select the advanced option and give condition in when to Run as " State changes to Closed" or as per the requirement.
In the advanced tab, write the following code:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord('change_request');
gr.addQuery('number',current.change_request);
gr.query();
while(gr.next()){
gr.setValue('state',3); //3 is the state for closed in my instance
gr.update();
}
var gs = new GlideRecord('change_task');
gs.addQuery('change_request',current.change_request);
gs.query();
while(gs.next()){
gs.setValue('state',3); //3 is the state for closed in my instance
gs.update();
}
})(current, previous);
It should work, if not, please let me know.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2018 05:49 AM
Sorry I don't understand how or where the closure type of 'Cancelled by Implement Task' would be factored into that section of the script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2018 11:28 AM
Basically, I have used state as your u_closure_type and 4 is the state for Cancelled by Implement Task.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2018 02:10 AM
OK yes that has worked. Thank you