- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2023 07:56 AM
Story should not be move to complete state until the associated defect of that story is not closed. I want to perform abort action.
What is the ideal way to use Business rule or flow designer ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2023 11:05 PM - edited 09-30-2023 11:18 PM
Hi @Balakrishna_ABK,
According to ServiceNow best practices, it's advisable to use Flow Designer if you can achieve the same configuration with a business rule or Flow Designer. However, in your scenario, the `current.setAbortAction(true)` only works in a Before business rule. For your reference, I'm attaching a link to a community thread: [Community Thread Link](https://www.servicenow.com/community/developer-forum/how-to-setabortaction-in-a-custom-action-in-a-f...).
If you wish to achieve the same result with a business rule, follow these steps:
**Step 1:** Create a Before business rule on the Story Table with the following conditions:
- State Changes to Complete
- And Defect.State is not Closed Complete
**Step 2:** In the Action Tab, check Add Message and Abort Action Field.
Once you complete these steps, you will observe that stories are not getting updated if the related defect is not Closed Complete.
Please mark ✅ Correct if this resolves your issue, and also mark 👍 Helpful if you find my response valuable based on the impact.
Regards,
Astik Thombare
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2023 10:16 AM - edited 10-01-2023 12:43 PM
I would recommend a before Update Business Rule, with the Filter Condition State changes to Completed. The script would check
if (current.defect.active == true) {
current.setAbortAction(true);
}
This will prevent any updates/changes from saving on the record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2023 09:50 PM
Hi @Balakrishna_ABK ,
You can use easily Business rule, with the condition section on "state" is "complete" & put below script.
if(current.associate_defect.active == "true"){
current.setAbotAction(true);
}
you can restrict closure of the story.
Please mark Helpful & correct if its helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2023 11:24 PM
Hi @Brad Bowman ,Thanks for your reply, I want to set state value to previous state in the same code

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2023 02:39 AM
@Balakrishna_ABK You should use the above script in an onBefore Update BR, since the script uses
current.setAbortAction(true)
No changes would take place and the record would still point to the previous statge.