Jira Automation: How to make story status change by completing story's subtasks
Asked by Jonathan Chatfield:

Hello,

I am wanting to have an automation that can change the status of a story at certain percentage threshold of changing the status of story's subtasks to done.

Ex: Story is called "Testing interface" and the current beginning status is **To Do**.

Then The story will have 10 subtasks: HIM, JIRA, POWERBI, etc. I want a formula to be exceeding 1% of changing the subtask status to **Done** , then will change the status to **In Progress** for the Story.

Then another formula that at 50% completed of the subtasks of the story will change the story's status to **Testing Server.**

Then a last formula that at 100% complete of the subtasks of the story will change the story's status to **Done.**

How do I accomplish this using Jira Automation?

Thank you,


Answers:
author: Kalyan Sattaluri
body: Hello [@Jonathan Chatfield](/t5/user/viewprofilepage/user-id/5489117)

Welcome to the community.

You havent mentioned if you are in Cloud or DC. If you have lookupIssues, its a lengthy but straight forward rule to implement. If you dont have lookupIssues, let us know so we can suggest alternatives.

Assuming you have lookupIssues, try to implement below steps to begin with:

* Trigger = Issue Transitioned to Done
* If Condition = Issue type = Sub-task
* lookupIssues =\> parent = {{issue.parent}}
* create Variable =\> (allSubtaskcount) = {{lookupIssues.size}}
* lookupIssues =\> parent = {{issue.parent}} and status = Done
* create Variable =\> (doneSubtaskcount) = {{lookupIssues.size}}
* Log statement =\> {{#=}}ABS({{donesubtasks}} / {{allsubtasks}} \*100){{/}}

If you can get upto here, next is a series of If Conditions \& Branch steps.

So try to get started with the rule, refer to screenshot and share screenshot of your rule / audit log at least until above steps and we can proceed further to do If Condition/Branch evaluation.

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/321823iD4A758886DBE8618/image-size/large?v=v2&px=999 "image.png")

comments: author: Jonathan Chatfield
body: Hello Kalyan,

Thank you for responding back to me so quickly! I am really enjoying Jira and wanting to have a automating way of helping the team out. I am not seeing a lookup issue button on the action's selections. Can you tell me if I am missing it? I love having both of your rules in my engine list so I will be building both just in case for the future! I do really appreciate the help and guidance!

![Jira.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/321897i4C1849CDB04E5F64/image-size/large?v=v2&px=999 "Jira.jpg")


author: Kalyan Sattaluri
body: Hello [@Jonathan Chatfield](/t5/user/viewprofilepage/user-id/5489117)

So, looks like you dont have lookupIssues. Which is fine. I am going to list you alternative steps. Can you replicate them and run the rule by transitioning a sub-task and sharing the audit log.

* Trigger = Issue Transitioned to Done
* If Condition = Issue type = Sub-task
* Log Statement = {{issue.parent.subtasks.size}}
* Log Statement = {{#=}} 0{{#issue.parent.subtasks}}{{#if(equals(status.name,"Done"))}} +1 {{/}}{{/}}{{/}}
* Log Statement = {{#=}}{{#=}}0{{#issue.parent.subtasks}}{{#if(equals(status.name,"Done"))}} +1 {{/}}{{/}}{{/}} / {{issue.parent.subtasks.size}} \*100{{/}}

As mentioned, implement the rule like I have in below and share screenshot with audit log. Once done, we can continue with the If/Branch logic I mentioned.

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/321907i3B73C890C248DD2D/image-size/large?v=v2&px=999 "image.png")


author: Jonathan Chatfield
body: ![Test Kalyan.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/321918iFCEC1E073CCA81D2/image-size/large?v=v2&px=999 "Test Kalyan.jpg")  
I am on config change status still. I have made a change to a subtask status from done to To Do and back to Done. I do not see like yours where it says the status on the rule is success.


author: Kalyan Sattaluri
body: Are you transitioning a sub-task to "done" for one which is in the same project right? LOL


author: Jonathan Chatfield
body: Hahahah now I am questioning everything! =P  
The word transition in jira is when you change the status correct or is transition something totally different?  
I have confirmed that this rule is on the same project since it shows the changes that I made clicking on the project itself


author: Jonathan Chatfield
body: ![Trans.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/321920i3234FD63C4B18295/image-size/large?v=v2&px=999 "Trans.jpg")  
I looked up transition online and we are on the test project to make sure everything works correctly as this is just a skeleton of what the main project looks like. So I do have it on the right project, here is the issuetypes and the transitions for them. Is there something wrong with this setup?


author: Kalyan Sattaluri
body: Hello [@Jonathan Chatfield](/t5/user/viewprofilepage/user-id/5489117)

Yes, transition in this context is to move an issue to Done.

I am not sure why your rule is not triggering.

Lets try a different thing just to confirm rule is going to get triggered.

Change your trigger from "Issue Transitioned" to "Scheduled Trigger" and in the JQL section on same screen, give a sub-task key which we will use to test. Like I have below screenshot. Notice the highlighted section, make yours like I have..

So change trigger, go to that sub-task and change it from In Progress to Done and share the audit log.

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/321953i4582E6163B975E21/image-size/large?v=v2&px=999 "image.png")


author: Jonathan Chatfield
body: ![Rule ran.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/321955i64627C814F260E75/image-size/large?v=v2&px=999 "Rule ran.jpg")![Screenshot1.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/321956iD3242632586E2354/image-size/large?v=v2&px=999 "Screenshot1.jpg")  
[@Kalyan Sattaluri](/t5/user/viewprofilepage/user-id/5312306) I have did what you asked and highlighted shows that it is pulling from that subtask and added the logs, I had changed the status twice from in progress back to done and ran it to show the same function happening.  

Your screenshot had the previous rule running that I do not have lookup functionality. I just wanted to remind you since we got so many screenshots haha! I do really appreciate you helping me and sticking with this. This is very kind of you!


author: Kalyan Sattaluri
body: Is HOC-174 a sub-task? Cause from the audit log it does not look like it.

Please replace it with a sub-task and transition that sub-task.


author: Jonathan Chatfield
body: ![Line.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/321957iCCF36AF8CAF472F2/image-size/large?v=v2&px=999 "Line.jpg")

![176.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/321958i35D63664D632DBB9/image-size/large?v=v2&px=999 "176.jpg")

It is a sub-task, I will change it to Cher hoc-176 and here is the log. I have changed the key to Cher then published it then went to hoc 176 cher then changed it to in progress to done then I pressed run rule button. I want to explain the steps I did to see if I did anything wrong! =D


author: Kalyan Sattaluri
body: Hmm, something's strange. One last thing, can you, before the If condition, add another log statement to check if HOC-176 is called sub-task or something different in your set up?

So, log {{issue.issuetype.name}} like I have in my screenshot, right after the trigger, run the rule and share screenshot..

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/321959i8C98711720BF66E0/image-size/large?v=v2&px=999 "image.png")


author: Jonathan Chatfield
body: Hey [@Kalyan Sattaluri](/t5/user/viewprofilepage/user-id/5312306) !  
So I got a screenshot with a success but tell me if it looks good. I see a issue condition that does not recognize hoc-176. I hope we are making progress! =D

![success.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/322098i36088F1BF65EFB68/image-size/large?v=v2&px=999 "success.jpg")


author: Kalyan Sattaluri
body: Hello [@Jonathan Chatfield](/t5/user/viewprofilepage/user-id/5489117)

I honestly am not sure why your "If condition" is not passing the check.

You may need to check with someone in your company on why thats happening as what I was sharing is expected behavior.

Either you are in a really old version of automation with bugs in software or there is something wrong with how your issue types are configured.

So please try to check in with someone in your company and share them this rule and ask why we cant get past the first If check.


author: Jonathan Chatfield
body: Hey [@Kalyan Sattaluri](/t5/user/viewprofilepage/user-id/5312306)

I knew your logic had to be correct, so I relooked at my if: issue condition and there are two Issue types selections from the dropdown menu to choose so I chose the other one and got an actually log it looks like! What else is there? ![Success1.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/322126i367A874F3B677508/image-size/large?v=v2&px=999 "Success1.jpg")


author: Bill Sheboy
body: Hi [@Jonathan Chatfield](/t5/user/viewprofilepage/user-id/5489117)

There is a typo in one of your log write smart values: *subtask* should be *subtasks*:

```
parent subtask count: {{issue.parent.subtasks.size}}
```

I recommend adding prefix text to log entries like this to confirm which value is logged.

Kind regards,  
Bill


author: Jonathan Chatfield
body: Hello [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313)

Thank you for spotting that! I looked into the log and see where that section didn't have information! That is good to know for future references for checking!!


author: Jonathan Chatfield
body: ![successor.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/322178i5C53F35476EAEFCC/image-size/large?v=v2&px=999 "successor.jpg")

Hey [@Kalyan Sattaluri](/t5/user/viewprofilepage/user-id/5312306)

After seeing that mistake, I went back to the code you previously sent and it seems to be working. I look forward to hearing your next steps to make this happen. I really appreciate all your help and this guidance is helping me understand what I need to type in these fields for the future! =D


author: Kalyan Sattaluri
body: Hello [@Jonathan Chatfield](/t5/user/viewprofilepage/user-id/5489117)

Good to hear you got past the first step.

Just FYI \& I should have explained it earlier itself- the last log statement we did was to calculate the % of done. That is:

{{#=}}{{#=}}0{{#issue.parent.subtasks}}{{#if(equals(status.name,"Done"))}} +1 {{/}}{{/}}{{/}} / {{issue.parent.subtasks.size}} \*100{{/}}

We will be using the above syntax as part of our check.. Hope you have tested with various combinations of sub-tasks in different states so you can check the % done calculations. If not, please do at this point.

Also, at this time, change the trigger back to "Issue Transitioned" as we first had it..

-----------------------------------------------------------------------------------------

Now, the next steps, its just a series of If/Else and branch statement.

I am going to list steps how your rule should continue, take a look at below set up, and modify according to the statuses you want...

So, After your last log statement, you will do:

Add Condition -\> If/Else Block:

* -\> Add Conditions -\> Advanced Compare condition,
  * {{issue.parent.status.name}}
  * "CONTAINS"
  * To Do,
* \&\&
* -\> Add Conditions -\> Advanced Compare condition,
  * {{#=}}{{#=}}0{{#issue.parent.subtasks}}{{#if(equals(status.name,"Done"))}} +1 {{/}}{{/}}{{/}} / {{issue.parent.subtasks.size}} \*100{{/}}
  * Less Than
  * 50
* Branch -\> For Parent
  * Transition Issue -\> In Progress

NOTE: the first check of "To Do" applies only for first case, for the rest of the else statements you dont need the status check . You can just check % done and transition.

MORE IMPORTANT NOTE: If you have transition workflow restrictions on story, that is, unless "Acceptance criteria" is filled in, you cannot go to "in progress" or similar, your rule will fail.. so you need to handle that after branch but before you transition the issue by doing Edit Issue and filling in the fields or whatever is needed to satisfy the transition...

I have included a first condition of the screenshot, you just need to include based on your requirement.

So, given first step is done, From here on, you just keep adding additional else clause and "additional conditions" for next series of checks you want to do. Should be straight forward.

So try to implement the same, play around with your requirements and make sure your If conditions are tight. That is, earlier we gave % done is less than 50, and we made it "in progress", next, give a specific range of % Done is greater than 50 and less than 75%, if so, transition to "testing server", equal to 100, transition to "Done"...

Its just a matter of testing all scenarios thoroughly. So try it and let us know.

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/322199i373D83326CD5BC00/image-size/large?v=v2&px=999 "image.png")


author: Jonathan Chatfield
body: ![Test 1.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/322204i0279002F1820683F/image-size/large?v=v2&px=999 "Test 1.jpg")![Test.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/322203iEC62B8131ECB570C/image-size/large?v=v2&px=999 "Test.jpg")

Hey [@Kalyan Sattaluri](/t5/user/viewprofilepage/user-id/5312306)

I feel like I typed everything like you did but there is something wrong with my If since I see the If block is saying did not match condition. Here is the code that I wrote:  

{{issue.parent.status.name}}  

Contains  

To Do  

{{#=}}{{#=}}0{{#issue.parent.subtasks}}{{#if(equals(status.name,"Done"))}} +1 {{/}}{{/}}{{/}} / {{issue.parent.subtasks.size}} \*100{{/}}  

Less than   

50  

Am I doing something wrong? Also I am attaching the main story screenshot as well just to show that I did 25%![iverview.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/322205i5ACFF422B26ABE71/image-size/large?v=v2&px=999 "iverview.jpg")


author: Kalyan Sattaluri
body: Your HOC-166 story initial state is "BACKLOG".

so change first If condition to:

* {{issue.parent.status.name}}  
  Contains  
  **BACKLOG**

Earlier it was To Do, because thats what I have as my initial state of story. So please take care of your status's names.


author: Jonathan Chatfield
body: Awesome, It works! Thank you for all this help [@Kalyan Sattaluri](/t5/user/viewprofilepage/user-id/5312306)  
I had to type Backlog and boom it all worked! I did a 50 percent In Progress and a 100 percent transition to Done status for the story!  

Now since the story automatically transitions because the trigger is me changing the subtasks, how can I change the same process but at a epic level when a certain amount of stories are done?  
I tried to run it but it is not going so well haha, but I am glad to be learning from this hands on way so I really do appreciate all this help!


author: Kalyan Sattaluri
body: Hello [@Jonathan Chatfield](/t5/user/viewprofilepage/user-id/5489117)

Great to hear. \*high fives\*

Regarding doing same thing with Epic/Stories, unfortunately its not possible the same way.

Stories/Sub-tasks are tightly coupled, in that sub-tasks cannot exist with out stories.. so we could do that here.. but Epic/Stories are not the same. Stories can exist without Epic, so we cannot use the same format.

To solve Epic/Story problem, and because you dont have lookupIssues, we need to rely on making a REST API calls to get that done.

If you havent set up one before, definitely an advanced topic, maybe start a new post with that requirement so discussion can stay focussed.

Now regarding this thread, if you feel the rule is working properly, please accept solution so the discussion benefits folks in the future. Thanks!


author: Jonathan Chatfield
body: Awesome! I will start a new topic and try to get that going! Thank you for all this help =D


author: Kalyan Sattaluri
body: Awesome, as mentioned, please dont forget to accept the answer so its marked as complete. Thanks!


author: Stefan Salzl
body: Hi [@Jonathan Chatfield](/t5/user/viewprofilepage/user-id/5489117) - welcome to the community,

I suggest the following:

whenever a subtask is set to done the rule should run and check for all subtasks in the story. This will be done with a lookupIssues (collect all done subtasks within the same parent).

then going through the options with if-else conditions calculating the percentage of done subtasks and transitioning the parent via parent-branch.

see the screenshot below (I just took the status I have in my system - need to be changed according your requirements):

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/321853i2EE2389AED987195/image-size/large?v=v2&px=999 "image.png")![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/321854i7DD0EB207BE1A9AA/image-size/large?v=v2&px=999 "image.png")![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/321855i952262653A889DB4/image-size/large?v=v2&px=999 "image.png")

Hope this was helpful. Let me know if you have any further questions.

Best  
Stefan

comments: author: Jonathan Chatfield
body: Hello Stefan,

Thank you for responding back to me so quickly! I am really enjoying Jira and wanting to have a automating way of helping the team out. I am not seeing a lookup issue button on the action's selections. Can you tell me if I am missing it? I love having both of your rules in my engine list so I will be building both just in case for the future! I do really appreciate the help and guidance!

![Jira.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/321897i4C1849CDB04E5F64/image-size/large?v=v2&px=999 "Jira.jpg")


author: Stefan Salzl
body: Hi [@Jonathan Chatfield](/t5/user/viewprofilepage/user-id/5489117)

Could you please show a screenshot of your rule details? Furthermore: which versions are you running (Jira as well as automation).

Could you please also try setting up a complete new rule with just the trigger, the first condition and the first audit log action? Sometimes it happens that up glitchy after editing or shifting components. Let's try if the same logic works in a newly created rule.

Another point that could be checked is the server log. If you arent able to acccess theog files ask your admin. The should be able to access.

Best  
Stefan


Tags: jira

status