- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2022 01:00 PM
Hello,
I am trying to write a business rule to update a story's state to complete when all the scrum tasks are in a state of complete or cancelled, but I am struggling to get it to work. I was hoping someone might be able to help me with my script. It is currently targeting the rm_scrum_task table, after update, and when the state changes.
(function executeRule(current, previous /*null when async*/ ) {
var gr = new GlideRecord('rm_scrum_task');
gr.addQuery('parent', current.parent);
gr.addQuery('state', '3');
gr.addQuery('state', '4');
gr.query();
while (gr.next()) {
if (gr.state == '3' || gr.state == '4') {
gr.parent.state == '3';
}
}
})(current, previous);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2022 01:50 PM - edited 11-11-2022 01:51 PM
Sorry there was a typo in my code. Can you try again?
(function executeRule(current, previous /*null when async*/ ) { var gr = new GlideRecord('rm_scrum_task'); gr.addQuery('parent', current.parent); gr.addActiveQuery(); gr.query(); if (!gr.next()) { var par = current.parent.getRefRecord(); if (par.isValidRecord()) { par.state = '3'; par.update(); } } })(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2022 01:50 PM - edited 11-11-2022 01:51 PM
Sorry there was a typo in my code. Can you try again?
(function executeRule(current, previous /*null when async*/ ) { var gr = new GlideRecord('rm_scrum_task'); gr.addQuery('parent', current.parent); gr.addActiveQuery(); gr.query(); if (!gr.next()) { var par = current.parent.getRefRecord(); if (par.isValidRecord()) { par.state = '3'; par.update(); } } })(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2022 02:00 PM
That worked, thank you for the help Mike!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2025 08:24 AM
Hello Mike, how would I do this when the scrum tasks are set to cancelled. How would I change the parent state to cancelled? This is the code I have so far:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2025 08:26 AM
The code you sent for the original worked perfectly. But when I run the code for the cancelled state, it is setting the parent to complete?