- 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:10 PM - edited 11-11-2022 01:49 PM
Try this
(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:33 PM
I tried that but when I updated the scrum task to complete the parent story was still work in progress.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2022 01:34 PM
Can you post a screenshot of your "When to run" tab of your business rule?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2022 01:42 PM