Update Stories Status when specific subtask issues types are moved into specific statuses

Hello,

 

We have a development team who is looking for us to configure workflows like so:

SUBTASKS

To Do-> In Prog-> Done

STORY

Open-> In Refinement-> To Do > In Prog -> Ready for test -> In Test -> Post testing> Done-> Closed


Stories cannot be manually transitioned through statuses, the transitions of subtasks will trigger this.

Subtasks currently = (Dev subtask, QA subtask, Performance Test subtask...)

GOAL: Set up the following post functions

-When Dev subtasks are moved to done, the story automatically transitions to the status of ready for test.

-When QA subtasks are moved from "In Test" to "Done", the story automatically transitions to post testing.



In short these are the auto transitions we would like to make

1st Dev subtask = In Progress, Story = In progress

All Dev subtasks = Done, Story = Ready fro Test

1st QA subtask = In progress and all Dev subtasks = Done, Story = In Test

All QA subtasks = Done and All Dev subtasks = Done, Story = Post Test

All Performance Test subtask = Done, Story = Done

 

 

I have found some info about how to do this here, but it has not been fully helpful in accomplishing my goal:

https://answers.atlassian.com/questions/268989

21 answers

Hi Matthew,

You can do it using JIRA Workflow Toolbox. There are several ways to accomplish what you intend to do. I'm going to describe one of them:

1) 1st Dev subtask = In Progress, Story = In progress:

Add post-function "Copy a parsed text to a field" with the following configuration into transition "To Do-> In Progress" of Dev Subtask's workflow:

  1. Target field: Parent's issue status
  2. Parsing mode: Advanced
  3. Text to be parsed:

    %{00042} = "To Do" ? "In Progress" : ""

Note that:

  • %{00042} is field code for virtual field "Parent's issue status"
  • "To Do" and "In Progress" should be correct statuses names in your JIRA instance.

2) All Dev subtasks = Done, Story = Ready for Test:

Add post-function "Copy a parsed text to a field" with the following configuration into transition "In Progress -> Done" of Dev Subtask's workflow:

  1. Target field: Parent's issue status
  2. Parsing mode: Advanced
  3. Text to be parsed: (a single line)
count(filterByIssueType(subtasks(%{00041}), "Dev Subtask")) = count(filterByStatus(filterByIssueType(subtasks(%{00041}), "Dev Subtask"), "Done")) + 1 ? "Ready for Test" : ""

Note that:

  • %{00041} is field code for virtual field "Parent's issue key"
  • "Done" and "Ready for Test" are correct statuses names in your JIRA instance.
  • "Dev Subtask" is correct issue type name in your JIRA instance.

3) 1st QA subtask = In progress and all Dev subtasks = Done, Story = In Test:

Add post-function "Copy a parsed text to a field" with the following configuration into transition "To Do-> In Progress" of QA Subtask's workflow:

  1. Target field: Parent's issue status
  2. Parsing mode: Advanced
  3. Text to be parsed: (a single line)

count(filterByIssueType(subtasks(%{00041}), "Dev Subtask")) = count(filterByStatus(filterByIssueType(subtasks(%{00041}), "Dev Subtask"), "Done")) ? "In Test" : ""

Note that:

  • %{00041} is field code for virtual field "Parent's issue key"
  • "Done" and "In Test" are correct statuses names in your JIRA instance.
  • "Dev Subtask" is correct issue type name in your JIRA instance.

4) All QA subtasks = Done and All Dev subtasks = Done, Story = Post Test:

Add post-function "Copy a parsed text to a field" with the following configuration into transition "In Progress -> Done" of QA Subtask's workflow:

  1. Target field:Parent's issue status
  2. Parsing mode:Advanced
  3. Text to be parsed: (a single line)

    count(filterByIssueType(subtasks(%{00041}), "Dev Subtask, QA Subtask")) = count(filterByStatus(filterByIssueType(subtasks(%{00041}), "Dev Subtask, QA Subtask"), "Done")) + 1 ? "Post Test" : ""

Note that:

  • %{00041} is field code for virtual field "Parent's issue key"
  • "Done" and "Post Test" are correct statuses names in your JIRA instance.
  • "Dev Subtask" and "QA Subtask" are correct issue type names in your JIRA instance.

5) All Performance Test subtask = Done, Story = Done:

Add post-function "Copy a parsed text to a field" with the following configuration into transition "In Progress -> Done" of Performance Test Subtask's workflow:

  1. Target field:Parent's issue status
  2. Parsing mode:Advanced
  3. Text to be parsed: (a single line)

count(filterByIssueType(subtasks(%{00041}), "Performance Test Subtask")) = count(filterByStatus(filterByIssueType(subtasks(%{00041}), "Performance Test Subtask"), "Done")) + 1 ? "Done" : ""

Note that:

  • %{00041} is field code for virtual field "Parent's issue key"
  • "Done" is correct status name in your JIRA instance.
  • "Performance Test Subtask" are correct issue type names in your JIRA instance.


You only have to modify parameter test to be parsed if the names for statuses and issue types I have used doesn't correspond exactly to the ones in your JIRA instance.

Regards,

Fidel Castro Armario

 

Hi Fidel, thanks again for all the help on this. I have an additional question that I'm hoping you might be able to help me with. We would like to ad the ability to add an additional dev subtask to a story in the current sprint after all the dev subtasks are moved to done. The reason for this is that some teams are telling us that at times additional dev items might be discovered during the sprint. Please let me know your thoughts on this. Thanks Matt

We can add post-function "Copy a parsed text to a field" to transition "Create Issue" in your dev subtask's workflows in order to automatically move parent issue ("Story") to "Open" status or any other one. Please, explain me which is your desired behavior for "Story" when a new subtask is created, and I will explain in detail how to implement it.

I was thinking that post function is what we needed, but was not sure how to set it up correctly. I describe the situation below. Let me know if you need more details. Scenario: "Dev Subtasks" = Done, "QA Subtasks" = To Do [or] In Prog, Story = "Ready for Test" [or] "In Test" ..... New Dev Subtask is created --> Story moves back to "In Progress"

I think that it makes sense to move Story to "In Progress" whenever a new Dev Subtask is created and Story is in statuses "Ready for test", "In Test", "Post testing", "Done" or "Closed". I explain how to do it in an answer below.

Hi Fidel, If we had a dev sub-task in progress, and QA sub-task in progress and status of the story was in progress, once we moved the dev sub-task to done our story would then move to ready for test, but we would are looking for story to actually transition into 'In Test' as we already have the QA sub-task in progress. How would this be possible?

Use the following parsed text in post-function 2: count(filterByIssueType(subtasks(%{00041}), "Dev Subtask")) = count(filterByStatus(filterByIssueType(subtasks(%{00041}), "Dev Subtask"), "Done")) + 1 ? (count(filterByStatus(filterByIssueType(subtasks(%{00041}), "QA Subtask"), "In Progress")) > 0 ? "Test" : "Ready for Test") : ""

Just to comment back on this - this change was made and it works. Sorry about late reply.

Hi Matthew,

I explain you how to make Story automatically move to status "In Progress" whenever a "Dev Subtask" is created and "Story" is in any of the following statuses: "Ready for test", "In Test", "Post testing", "Done" or "Closed".

Add post-function "Copy a parsed text to a field" with the following configuration into transition "Create Issue" of Dev Subtask's workflow:

  1. Target field:Parent's issue status (delayed writing)
  2. Parsing mode:Advanced
  3. Text to be parsed:

    %{00042} in ["Ready for test", "In Test", "Post testing", "Done", "Closed"] ? "In Progress" : ""

The workflow of "Story" issues must contain a transition from any of those statuses to status "In Progress" in order to be able to move the issue to this status. In case any of these required transition doesn't exist, you can create one and hide it to interactive users using condition "Transition is triggered by JIRA Workflow Toolbox post-function".

Thanks Fidel! This worked, it moves the story to "In Progress" once the dev subtask is created + moved to "In Progress", but once that new Dev Sub-task is closed (with QA sub task still "In Progress") the story moves to "Ready for Test" instead of the expected "In Test". How would we write a post function that keeps the story "In Test" in this above situation? Another issue we are finding once this new post function is added. When a story has 2 or more Dev Sub-tasks are in the initial story, and these 2 Dev Sub-tasks are moved to done, the status of the story goes to "Ready for Test" (expected). But once the QA Sub-task is moved to "In Progress", the story stays at "Ready for Test". One additional issue: Dev Sub-task = "In Progress" AND QA Sub-task = "In Progress" .. Story = "In Progress" (expected) ..then Dev Sub-task transitions to Done, QA Sub-task remains In Progress ..Story = "Ready for Test" (should be "In Test") All three of these scenarios run into the same issue of the story not transitioning to "In Test", but all three seem somewhat different so I wanted to describe them all to you. Thanks!

Hi Matthew, Problem 1 and 3 have the same cause. You can solve them replacing text to be parsed in post-function 2) with the following one: count(filterByIssueType(subtasks(%{00041}), "Dev Subtask")) = count(filterByStatus(filterByIssueType(subtasks(%{00041}), "Dev Subtask"), "Done")) + 1 ? (count(filterByStatus(filterByIssueType(subtasks(%{00041}), "QA Subtask"), "In Progress")) > 0 ? "In Test" : "Ready for Test") : "" or since version 2.2.1, you can use the following text which a bit simpler: count(filterByIssueType(siblingSubtasks(), "Dev Subtask")) = count(filterByStatus(filterByIssueType(siblingSubtasks(), "Dev Subtask"), "Done")) ? (count(filterByStatus(filterByIssueType(siblingSubtasks(), "QA Subtask"), "In Progress")) > 0 ? "In Test" : "Ready for Test") : "" In relation to problem 2, I have a question: When you say you have moved the 2 (or more) preexisting dev subtasks to "Done" status, do still rest some newly created dev subtasks in statuses "To Do" or "In Progress"?

In problem 2 their are no other dev sub-tasks. All the Dev sub-tasks are moved to done. The solution you have provided resolves all 3 of the issues we are seeing. The story now moves back to "In Progress" when new Dev Sub-tasks (or Qa subtasks) are created, and the story status progresses as expected when the remainder of subtasks are moved through the story.

Hi Fidel,

Would it be possible to block a story to progress throught it's statuses if we had a QA sub-task that is used for test case creation. Our thoughts are that if there is a QA sub-task that moves first throught stories and has a specific label or a specific field, story should always stay in to do, causing the auto-tranisition to work according to how we set it up.

 

At this moment we have a team that uses QA sub-task for test case creation and it's moved through it's workflow and closed/ done before any dev sub-task or other qa sub-task are worked on.  This is causing the story to move into 'Ready for Test' status, while still having sub-task in to do status.

Hi @Fidel Castro Armario,

Thanks so much for your reply! We just tried setting the post functions up as described, but are not seeing any transition occur on the story. 

Do you have any recommendations on what we might be doing incorrectly? I verified that the syntax of our statuses in JIRA are correct in the scripts, not sure what else is going on here.

 

Thanks again for your invaluable guidance laugh

 

Matt

Here is an attachment of our Post FunctionsPostFunctions.png

The user that is executing interactively the sub-task's transition should also be able to execute the transition in parent issue, or you can use parameter "Run as" to select another user which permission to execute the transition. Anyway, If you need to hide the transition in parent issue to the interactive users, the best option is to use condition "Transition is triggered by JIRA Workflow Toolbox post-function", which will hide the transition, but will keep it available to JIRA Workflow Toolbox post-functions.

Hi Fidel,

After doing some more investigation we have found that we were using the wrong target field. Their are apparently 2 target fields with nearly identical names. Once we change this change we were able to resolve our problem and get this working. 

The other field is "Parent issue (delayed writing)", which waits for current transition (i.e., subtask) to end its execution, before trying to change status in parent issue. This field is useful when parent issue has conditions or validations which depend on subtask' statuses, preventing parent issue from being executed.

There is detailed explanations and usage examples of the virtual fields in the plugin at documentation site.

Hi DF,

Yes, it's possible to do it, but there is something I don't understand. According to your current post-function configurations QA Sub-tasks only can move parent Story to statuses "In Test" (post-function 3) and "Post Test" (post-function 4).

Then, how is it possible that Story is being transitioned to "Ready for Test" by a QA Sub-task?

Yes, that was the goal of our post function and the way we have it set up from above directions works well, if a dev sub-task is moved first to 'in progress'.  One of the teams would always has a QA sub-task that would go through 'in progress' & 'done' before anything else would get started working on.  This is causing the workflow to follow the story transitioning as a dev sub-task would. 

I am assuming that the cause of this is because all our sub-task are on the same workflow and that our first post function is %{00042} = "To Do" "In Progress" ""which does not specify which sub-task is moving a story to 'in progress'.  

Even if we were to fix this, we still would not want to the QA sub-task with specific label or field that we set to move the story anywhere because this sub-task is just used for test case creation and always finishes first well ahead of any dev sub-task are being worked on.

Thanks

But expression %{00042} = "To Do" "In Progress" "" is in post-function 1, which I'm assuming that is only in Dev Subtask's workflow, not in QA sub-task's. Is that post-function also in QA sub-task's workflow?

Sorry for so many questions, but I need to fully understand what is happening in order to give your the right solution.

No not a problem, ask as many as you like, we surely do appreciate all your help.

All our Sub-task (Dev, QA, Performance) are on the same workflow.  They are not individually divided, so %{00042} = "To Do" "In Progress" would move the story to in progress if any of the sub-task moved first. I guess to solve this we could change the post-function 1 to say dev sub-task moves in progress, story moves in progress and then just add another post-function that when a specific qa sub-task with a label or field moves, nothing happens to the story.


Ok, now I understand the whole scenario. Do the following change:

Post-function 1:

(%{00014} = "Dev Subtask" AND %{00042} = "To Do") ? "In Progress" : ""

I'm assuming that "Dev Subtask" is the exact name of the issue type. Please, correct it if necessary.

I think I need to give you some more changes, but first I need that you tell me which version of JIRA Workflow Toolbox are you using, and which is the expression you are using in post-function 2, since I gave you some updates and I'm not sure if you applied them, or not.

I will update the Post Function 1. Our Workflow Toolbox version is 2.2.1

This is what we have on the Post function 2:

count(filterByIssueType(subtasks(%{00041}), "Development Sub-task, UX Sub-task")) = count(filterByStatus(filterByIssueType(subtasks(%{00041}), "Development Sub-task, UX Sub-task"), "Done")) + 1 ? (count(filterByStatus(filterByIssueType(subtasks(%{00041}), "QA Tests Sub-task"), "In Progress")) > 0 ? "In Test" : "Ready for Test") : ""

this is the version that you gave us later on

also (%{00014} = "Dev Subtask" AND %{00042} = "To Do") ? "In Progress" ""

is this a misspelling and it's 00041, and not 00014?

I think that no further changes are needed.

Only a remark: after having checked up your current configuration for post-function 2, I think that "UX Sub-task" subtasks are receiving a similar treatment as "Development Sub-task". In that case, perhaps you should use the following expression for post-function 1:

(%{00014} in ["Development Sub-task", "UX Sub-task"] AND %{00042} = "To Do") ? "In Progress" : ""

Fidel,

After making the changes to post function 1, story does not progress at all. I have tried moving Dev and UX sub-task and story just stays in to do.  It changed to 'In Test' once i dragged  QA Sub-task to In progress, while both Dev and UX sub-task were in done.

 

The only explanation I find Story remaining blocked in "To Do" status is that "Development Sub-task" and "UX Sub-task" have case difference with the actual name of those issue types. You can check the exact issue type names at JIRA Administration > Issues > Issue types.

You can also try the following expression, which uses case-insensitive comparisons:

(toUpperCase(%{00014}) in [toUpperCase("Development Sub-task"), toUpperCase("UX Sub-task")] AND %{00042} = "To Do") ? "In Progress" : ""

By the way, those names are working correctly with function filterByIssueType() because it does case-insensitive comparisons.

I have triple checked the case difference and i am not seeing any. This is what i get when i copy parse the text field

The following text parsed in advanced mode will be copied to Parent's issue status: 
(%{Issue type} in ["Development Sub-task", "UX Sub-task"] AND %{Parent's issue status} = "To Do") ? "In Progress" : "" 
This feature will be run as user in field Current user.

Would getting the post function above resolve the issue of a QA sub-tasking moving through it's workflow and effecting the story statuses. Our main goal is to make sure that when one QA sub-task with a specific label or field goes through the story stays the same. This is only being done by one team and that is why we were just made aware of the issue now. Everyone else is more less using Dev Sub-task first or along with QA Sub-task and story statuses are moving along just fine.

Update:

I got the UX and Dev to work now, and story stays in 'To Do' if i was to move a QA sub-task first, but once i close that QA sub-task out, story moves to In Test, with Dev and QA sub-task still in To Do

Fidel,

What option would work for us if we went along with blocking story to transition if there is a label or field?

Then do the following change:

Post-function 2:

(%{00014} in ["Development Sub-task", "UX Sub-task"] AND count(filterByIssueType(siblingSubtasks(), "Development Sub-task, UX Sub-task")) = count(filterByStatus(filterByIssueType(siblingSubtasks(), "Development Sub-task, UX Sub-task"), "Done"))) ? (count(filterByStatus(filterByIssueType(siblingSubtasks(), "QA Tests Sub-task"), "In Progress")) > 0 ? "In Test" : "Ready for Test") : ""

I think that you don't need to do more changes, since that special QA Sub-tasks is being moved while "Development Sub-task" and "UX Sub-taks" are resting in "To Do" status, not being necessary to mark the QA sub-task adding a special label, or giving a special value to a field.

Please, let me know if this change is enough, or we need to do modifications in the rest of post-functions.

This seems to have worked. I'll do some more re-test. 

Just to recap:

1st post function was changed:  (%{00014} in ["Development Sub-task", "UX Sub-task"] AND %{00042} = "To Do") ? "In Progress" : ""

2nd post function was changed: (%{00014} in ["Development Sub-task", "UX Sub-task"] AND count(filterByIssueType(siblingSubtasks(), "Development Sub-task, UX Sub-task")) = count(filterByStatus(filterByIssueType(siblingSubtasks(), "Development Sub-task, UX Sub-task"), "Done"))) ? (count(filterByStatus(filterByIssueType(siblingSubtasks(), "QA Tests Sub-task"), "In Progress")) > 0 ? "In Test" : "Ready for Test") : ""

 

Hopefully, this change to post function 2 does not change the previous auto-transitions.

 

Thanks

It should work as you expect. 

Hi @Fidel Castro Armario,

Hope all is well for you smile 

I have another small question on this topic if you might be able to lend some more advice. 

We are looking to expand this post function to trigger auto transitions on the bug workflow too. Currently, when a user moves the Dev subtask under a story to In Progress, the Story moves to In Progress.

The only difference between our Story and Bug workflow is that the Story workflow goes: "To Do" -> "In Progress", and the Bug workflow goes: "To Do" -> "Development In Progress".

We are trying to figure out a way to add an "or" to the post function to include the "Development In Progress" status...

Currently the post function is:

(%{00014} in ["Development Sub-task", "UX Sub-task"] AND %{00042} = "To Do") ? "In Progress" : ""

Example of what we are looking to accomplish:

(%{00014} in ["Development Sub-task", "UX Sub-task"] AND %{00042} = "To Do") ? "In Progress" OR "Development In Progress" : ""

 

We have tried using "OR", +, |, and a few other things.. We also tried just creating 2 post functions, one for each status. We also experimented with the Execute Transition - [Workflow Status] .. But none of these worked.

We are confident that the issue is with the status being "Development In Progress" (as opposed to "In Progress") because the autotransitions for "Ready for Test" and "In Test" that are in both the Bug and Story workflow after their In Progress steps still are triggered when the Dev Subtask is moved to done and only a QA subtask remains in To Do, or In Progress. 

Hi Matthew,

Try the following text to be parsed:

(%{00014} in ["Development Sub-task", "UX Sub-task"] AND %{00042} = "To Do") ? "In Progress" : (%{00014} in ["Bug"] ? "Development In Progress" : "")

We changed the post function to what you suggested and got no errors, but still not seeing the parent status update when the subtask is transitioned. 

Screen Shot 2016-07-25 at 2.12.00 PM.png

Sorry, I misunderstood your scenario. Please, use the following text to be parsed:

(%{00014} in ["Development Sub-task", "UX Sub-task"] AND %{00042} = "To Do" AND %{00040} = "Story") ? "In Progress" : (%{00014} in ["Development Sub-task", "UX Sub-task"] AND %{00042} = "To Do" AND %{00040} = "Bug" ? "Development In Progress" : "")

You should correct the string literals for the issue types if they are not exactly written: "Bug" and "Story".

Hi Fidel,

When the last sub-task is moved to `Deployed` Status by `Deploy` transition,
I need to auto close the parent ticket.

We know how to close parent ticket when all subtasks are closed.

I am using following code, but not able to close parent ticket.

 

count(filterByIssueType(subtasks(%{00041}), "Patch Source Core Request Sub-Task")) = count(filterByStatus(filterByIssueType(subtasks(%{00041}), "Patch Source Core Request Sub-Task"), "Deployed")) + 1 ? "Closed" : ""

Can give me advice, thanks in advance. 

Regards,

Suresh

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Dec 10, 2018 in Confluence

Organizing your space just got easier - Page Tree Drag & Drop is here

Hi Community! I’m Elaine, Confluence Product Manager. You may have read my earlier post about page tree in space navigation sidebar. I'm excited to share another improvement that helps you organize ...

212 views 6 8
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you