- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2024 10:35 PM
I have a requirement to prevent story closer if defect is still active.
I tried with writing BR but not working.
(function executeRule(current, previous /*null when async*/) {
// Query the defect table for associated defects
var defectGr = new GlideRecord('rm_defect'); // Replace 'rm_defect' with the actual defect table name
defectGr.addQuery('story', current.sys_id); // Assuming 'story' is the reference field on the defect table
defectGr.addQuery('state', '!=', 'Closed'); // Replace 'state' and 'Closed' with actual field and value
defectGr.query();
if (defectGr.hasNext()) {
// Prevent the story from being closed
gs.addErrorMessage('This story cannot be closed because it has associated defects that are still open.');
current.state = previous.state; // Revert the state change
gs.log('Story closure prevented due to open defects: ' + current.number, 'Story Closure Rule');
}
})(current, previous);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2024 11:14 PM
Hi @Prakash_S ,
You can achieve it via configuration of BR.
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2024 11:20 PM
Hi @Prakash_S ,
Why don't use defect field on the story to check if still active and abort action.
You don't need to any scripting logic
Step 1)
step 2)
Hope this helps!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2024 11:20 PM
Hi @Prakash_S ,
Why don't use defect field on the story to check if still active and abort action.
You don't need to any scripting logic
Step 1)
step 2)
Hope this helps!!!