Automation condition to transition parent status based on subtask approval

AT October 3, 2023

I want to create an automation (for a company managed project) where story/bug issue type can transition from To Do state to In Progess only if 1. subtask approval is present AND 2. subtask approval is approved. If the sub-task approval is missing OR if it is not approved, I am thinking the 'In Progress' state will simply not be present in the state dropdown.

Thanks!

1 answer

1 accepted

0 votes
Answer accepted
Giovanni Melai
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 3, 2023

HI @AT

What you described is not an Automation but a Transition Condition in the Workflow, in this case in the workflow of the Story/Bug.

I can think about one way to do it out of the box even if maybe not the best.

What you can do is use the "Sub-Task Blocking Condition" where you can select the statuses you want the subtasks to be for the transition to be available to the user.

A pre-condition is that you should automatically create the Approval subtask when the Story/Bug is created, so you are sure it's always present, this won't work if the Approval subtask does not exist.

You should then define dedicated Statuses for the Approval Subtask (like "To be approved" and "Approved"), that you are not going to use in other Subtasks in the same project.

Now you can create the "Sub-Task Blocking Condition" and select all the statuses except "To be approved", in this way the transition will not be available only if the Approval Task is in that status.

Said this, I'm not sure if this is the best approach to managing approvals in a Software project, I would instead add an approval status in the Story/Bug workflow, maybe before "To Do" and limit the transition from that first status to "To Do" only to the specific people that should have the ability to approve it. You can do this based on a project role or a Jira group.

I hope this helps

AT October 3, 2023

Thank you for the response Giovanni. 

So we do a have an automation now so that any time a story or  bug issue is created, a sub-task approval is automatically created. The states used in sub-task are unique to sub-task.

My question for you is from where and how do I create a sub-task blocking condition?

This is company managed project so I cannot directly add conditions in the workflow (it is set to read only as many project used the same workflows). However, I can use automation for my project.  I tried using following automation, but it still allows to change the parent story/bug status to In Progress, even is sub-task is not approved. 

Subtask approval.png

Giovanni Melai
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 3, 2023

If you cannot change the Workflow you are not able to achieve what you have in mind. Because the workflow condition is the only way to block the transition, with Jira Automation you can only act after something happened.

You should ask your Jira Administrator to configure a dedicated workflow for your needs. 

The only thing you can do with Automation is when someone transitions a Story/Bug to "In Progress" you can check if there is an approved Approval subtask and if it's not the case you can automatically transition the Story/Bug back to "To Do", maybe also adding a comment mentioning why it was moved back. 

I hope this makes sense 

AT October 3, 2023

Unfortunately, due to scale of JIRA we use at our organization getting this approval to allow changing workflow condition will likely not happen.

Your response on automation is helpful. Can you help me figure out how do I set the variable for this transition to happen. This would meet what I am trying to achieve.

Pls check the screenshot I shared before. That automation conditions are not doing what I wanted.Subtask approval.png

Giovanni Melai
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 4, 2023

Hi @AT ,

This should work. You just need to match all the correct statuses.

In your case the JQL to be used in the "Related issue condition" is something like this:

issuetype = Approval AND status = "To be approved"

Screenshot 2023-10-04 at 09.28.16.png

Like AT likes this
AT October 4, 2023

Thank you so much. Thats exactly what I was looking for. 

Like Giovanni Melai likes this
AT October 13, 2023

@Giovanni Melai Can you help with one more thing here.

Above you have helped me define that if a story/bug does not have an approval then automation moves it back to 'To Do' state. I want to add two more conditions:

1. If a story/bug DOES NOT have an approval sub-task, automation will move it back to previous state.

ALSO

2. If a story/bug DOES NOT have an approved status on the approval sub-task, automation will move it back to previous state (Currently, it moves it back to To Do. Is it possible to simply move it back to last state story/bug was in - To, Researching, Ready, Blocked)

Giovanni Melai
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 16, 2023

Hi @AT , sure.

1. for the first one, this was a bit tricky to find out because there are a few different cases to catch:

  • Stories with no subtasks at all
  • Stories with only subtasks that are Approvals
  • Stories with only subtasks that are not Approvals
  • Stories with both subtasks that are Approvals and not Approvals

You can use an IF/ELSE condition configured in the following way:

Screenshot 2023-10-16 at 10.53.26.png

In your case the JQLs will be something like:

status = "To Do" AND issuetype = Approval

and

issuetype != Approval

I tested it a bit and it seesm to work well.

2. for the second point to be able to go back to the previous status you can use smart values.

First you need to create a variable with the original status 

Screenshot 2023-10-16 at 11.01.50.png

Here the smart value to use for copy & paste:

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

Then you can use the variable in the transition Action like this:

Screenshot 2023-10-16 at 11.03.10.png

Cheers

AT October 18, 2023

Thank you! I did create a separate automation for stories/bugs where no approval sub-task is present and that covered the scenario I was looking for. 

But I will recheck if I should follow what you suggested. Thank you for your time so much.

Like Giovanni Melai likes this

Suggest an answer

Log in or Sign up to answer