Abort close of story state

Balakrishna_ABK
Tera Guru

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 ?

1 ACCEPTED SOLUTION

Astik Thombare
Tera Sage

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

 

AstikThombare4_0-1696140209225.png

 

 

**Step 2:** In the Action Tab, check Add Message and Abort Action Field.

AstikThombare4_0-1696141050516.png

 

 

Once you complete these steps, you will observe that stories are not getting updated if the related defect is not Closed Complete.

AstikThombare4_2-1696140280543.png

AstikThombare4_3-1696140292721.png

 

AstikThombare4_1-1696141096753.png

 

 

 

 

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

View solution in original post

9 REPLIES 9

Brad Bowman
Kilo Patron
Kilo Patron

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. 

 

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.

 

Hi @Brad Bowman  ,Thanks for your reply, I want to set state value to previous state in the same code

@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.