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

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

hi @swastikp3 , Thanks for your reply, I want to set state value to previous state in the same code

Astik Thombare
Tera Sage

Hi @Balakrishna_ABK 

 

As per the screenshot, the State field is not set to complete. If you refresh the page, it will return to the same state because we are aborting the action using the "Abort Action" field.

 

When the page is not refreshed:

AstikThombare4_0-1696147558286.png

 

When the page is refreshed:

AstikThombare4_1-1696147578849.png

 

 

 

Please mark Correct if this resolves your issue. Also, mark 👍 Helpful if you find my response valuable based on the impact.

 

Regards,

Astik Thombare

Hi @Balakrishna_ABK ,

 

Please,mark my answer as correct if it helps you.

 

Regards,

Astik Thombare

Hi @astik, I want to set value before refreshing the page.