Automation should block status change
Asked by Pauline Hild:

Hi everyone,

I need an automation that prevents a subtask from being set to "Done" status if certain conditions are not met (customfield ("LIMS") not yet filled and summary contains certain words ("Data Analysis" and "Data Transfer")). If the conditions are not met, the status should automatically be set back to the previous status. There is always a problem with this step (see screenshot error message).

I have already researched and often read that either the actor of the automation does not have the authorization or the transition is not possible in the workflow. Neither applies in my case.

Any ideas what else the problem could be?

Many greetings

Pauline

![Bildschirm?foto 2023-04-19 um 14.33.12.png](/t5/image/serverpage/image-id/252668i68608FF0FD863CB0/image-dimensions/165x348?v=v2 "Bildschirm?foto 2023-04-19 um 14.33.12.png")![Bildschirm?foto 2023-04-19 um 14.33.49.png](/t5/image/serverpage/image-id/252669i9FB6951E68D69B34/image-dimensions/325x172?v=v2 "Bildschirm?foto 2023-04-19 um 14.33.49.png")![Bildschirm?foto 2023-04-19 um 14.39.54.png](/t5/image/serverpage/image-id/252670i1396E3550BC193C3/image-size/large?v=v2&px=999 "Bildschirm?foto 2023-04-19 um 14.39.54.png")


Answers:
author: Trudy Claspill
body: Hello [@Pauline Hild](/t5/user/viewprofilepage/user-id/4773022)

Though you say you want to "prevent" the transition with the rule, I see from your additional text that you understand you have to actually undo the transition after it has occurred.

I believe your problem is your use of the smart value {{issue.previous.status}} in this step

![Screen Shot 2023-04-19 at 3.21.41 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/252843i71EC328CA46B53E2/image-size/large?v=v2&px=999 "Screen Shot 2023-04-19 at 3.21.41 PM.png")

Can you show us the details of that step?

Also, can you tell us where you go the idea to use that smart value? I found it mentioned in [this post from 2021](https://community.atlassian.com/t5/Jira-questions/Automation-for-Jira-Transition-to-previous-state/qaq-p/1661089). However, in that post it becomes clear that it is actually a reference to a custom field named **Previous status** which has been added to the project issues, and is being filled in during each transition so that there is a record of the previous status for the issue.

Have you created the custom field **Previous status** and are you setting its value each time the issue is transitioned? If you are setting it, can you provide information about how you are setting it?

comments: author: Pauline Hild
body: I didn't find a way to block the transition, so I thought I could just undo the transition. Is there also a way to prevent the transition directly?

I found the smart value in some other posts, so I thought this must be the right one. However, I don't have a "Previous status" field. Is there a smart value that has this function?

![Bildschirm?foto 2023-04-20 um 15.40.35.png](https://community.atlassian.com/t5/image/serverpage/image-id/252957iE158B296C82ECAB0/image-size/large?v=v2&px=999 "Bildschirm?foto 2023-04-20 um 15.40.35.png")


author: Trudy Claspill
body: Hello Pauline,

As [@John Funk](/t5/user/viewprofilepage/user-id/7148) mentioned you can't prevent a transition with an Automation Rule. Automation Rules run in reaction to an event. If you want to prevent, rather than undo, the transition you would need to modify the workflow transition to the Done status adding Conditions and/or Validators (or Rules, if you are working in a Team Managed project) to prevent the transition.

I have not worked out if the conditions you specified could all be set up between Transition Conditions and Validators (or Team Managed project Transition Rules) with native functionality.

In an Automation Rule, you can use the {{changelog}} smart value to look at changes that were made to the issue. This is mentioned in the [documentation for the Issue Transitioned Trigger](https://support.atlassian.com/cloud-automation/docs/jira-automation-triggers/#Issue-transitioned) and more information can be found [smart values for Issues documentation](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-issues/#--changelog--) .

In this case you would get the numeric value of the previous status using the smart value:

```
{{#changelog.status}}{{from}}{{/}}
```

You have to use the Create Variable action to store that in a variable.

![Screen Shot 2023-04-20 at 8.43.06 AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/252998iFEA945577657575C/image-size/large?v=v2&px=999 "Screen Shot 2023-04-20 at 8.43.06 AM.png")

Then you can use the variable smart value in the Transition Issue action.

![Screen Shot 2023-04-20 at 8.43.40 AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/252999iAA0BFE16133CD82A/image-size/large?v=v2&px=999 "Screen Shot 2023-04-20 at 8.43.40 AM.png")


author: Pauline Hild
body: I created the automation rule as you suggested and with this smart value it actually works, that's awesome! Thank you so much for your help!!!


author: Troy Anderson
body: Don't forget to reset the Resolution field as well!


author: John Funk
body: Hi Pauline,

Automation cannot prevent things from happening, it can only react to things that do happen. You would need a Validator (and/or Condition) on the transition in the workflow to keep it from transitioning in certain cases.

You don't want to just let them move it to Done and then if the criteria is not met, use automation to move it back. Prevent them from moving it in the first place.


Tags: cloud

jira-work-management-cloud