How to check whether all the stories are closed in an EPIC?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2023 10:22 AM
Hi All,
How do you check whether all the stories are closed in an EPIC?
Can you provide me the GlideRecord scripting to check all the stories associated with EPIC were closed
before the closing of the last story? I need to complete the EPIC state based on the last story closure value of an EPCI
Thanks
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2023 10:34 AM
(function executeRule(current, previous /*null when async*/) {
// Check if the record being updated is an Epic and the state is being changed to "Closed"
if (current.state == 'Closed' && previous.state != 'Closed') {
// Query all related stories
var story = new GlideRecord('rm_story');
story.addQuery('epic', current.getUniqueValue());
story.addQuery('state', 'Open');
story.query();
// Check if any stories are still open
if (story.hasNext()) {
// If there are open stories, prevent changing the Epic state to "Closed"
gs.addErrorMessage("Cannot close the Epic because there are associated open stories.");
current.state.setDisplayValue(previous.state.getDisplayValue()); // Revert the state change
current.setAbortAction(true);
return;
}
}
})(current, previous);