- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2018 08:32 AM
I have a requirement where if a change request is "closed skipped" meaning the state is put into "closed skipped"
all of the change tasks (usually around 7) associated with the change request are to have their state set to "closed skipped" as well. I am not a coder and the business rule I created is not working. Any help would be welcome.
thanks.
Business rule.
Table = change_request
When to run:
when= after
insert and update are checked
condition: state changes to "closed skipped".
Advanced :
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord('change_task');
gr.get(current.change_task);
gr.state = 7; //this needs to be the value of your closed skipped choice
gr.update();
})(current, previous);
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2018 08:54 AM
Here you go.
(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', '!=', 7);
gr.query();
while(gr.next())
{
gr.state = 7; //this needs to be the value of your closed skipped choice
gr.update();
}
})(current, previous);
-Pradeep Sharma

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2018 08:54 AM
Here you go.
(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', '!=', 7);
gr.query();
while(gr.next())
{
gr.state = 7; //this needs to be the value of your closed skipped choice
gr.update();
}
})(current, previous);
-Pradeep Sharma

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2018 08:54 AM
Here you go. You'll want this to run in an 'after' 'update/insert' business rule.
(function executeRule(current, previous /*null when async*/) {
// Query for associated change tasks
var gr = new GlideRecord('change_task');
gr.addQuery('change_request', current.sys_id);
gr.addActiveQuery();
gr.query();
while (gr.next()) {
gr.state = 7; //this needs to be the value of your closed skipped choice
gr.work_notes = 'Change task closed due to closure of Change request.');
gr.update();
}
})(current, previous);
Please mark this answer as correct if I've answered your question. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2018 09:38 AM
Thank you both. So glad to see your back Mark!
How do I mark you both as correct??