Switching epic automatically to done, if all linked issues are done.

Issue #686 resolved
Steffen created an issue

Hello Fidel,

first of all, I'm a JIRA beginner :) So please don't treat me for stupid questions.

My problem: I've got epics with different linked issue types (tasks, requirements and tests). Each of this issue type has a different workflow with different status. I want the epic to switch automatically to "Done" if all the linked issues are in their "final" status.

I already solved the problem with post function, but only for one issue type. Logically this solution won't work as soon as a different workflow/issue type is added.

How can i solve d´this problem?

Cheers,

Steffen

Comments (15)

  1. Fidel Castro Armario repo owner

    Hi @Steffen1305,

    Your question is very interesting. Please, attach a screenshot of the post-function you have configured.

    Can we use any of the following criteria to find out "final" statuses?

    1. Final statuses are the only ones were Resolution is set.
    2. Final statuses are the only ones with Done status category.

    Status Category is a special attribute of statuses you can define. Look at the screenshot:

    status_category.png

  2. Steffen reporter

    The final status should be the 2nd one, so that the issue is considered finished.

    Post_Function.png

    Note: Please don't ask me (perhaps you can explain it to me?) why I have to subtract 1 .... ;) And please ignore "Validated", it was a try to solve this issue.

  3. Fidel Castro Armario repo owner

    Hi @Steffen1305,

    Sorry, but I don't understand what you mean by "The final status should be the 2nd one...". Do you mean that final statuses are those with Done status category?

    In relation with - 1 in the expression: You are inserting the post-function in child issue's final transition. When the last child issue is being moved to final status, all the sibling child issues are already in final status, but current one is not yet, that's why we have to subtract 1 from the total number of child issues.

  4. Steffen reporter

    Yes, the final status are those with Done status category.

    When the last child issue is being moved to final status, all the sibling child issues are already in final status, but current one is not yet, that's why we have to subtract 1 from the total number of child issues. Okay, this makes sense! Thanks.

  5. Fidel Castro Armario repo owner

    Hi @Steffen1305,

    You can do it using the following boolean expression at parameter "Filtering by field values:":

    count(filterByFieldValue(linkedIssues("is Epic of", ^%{00015}), %{00144}, =, "Done")) = count(linkedIssues("is Epic of", ^%{00015})) - 1
    

    where %{00015} is field code for issue key, %{00144} is field code for issue status category, and "Done" is a string with the exact name of the status category of final statuses.

  6. Steffen reporter

    Unfortuneatly this doesn't work :( I thought %{00015} is the field code for issuekey ? Issuestatus should be {00016} but in my understanding issuekey should be the right parameter.

    For my understanding:

    linkedIssues("is Epic of", ^%{00015}) lists all issues under the same epic like current issue

    filterByFieldValue(xxx, %{00144}, =, "Done") filters the above list due to Status Category= Done

    For me this should work, but it isn't.

  7. Fidel Castro Armario repo owner

    Hi @Steffen1305,

    Let's do some debug: use "Copy a parsed text to a field" post-function with the following configuration in order to get the values returned by the 2 terms of the expression:

    • Target field: New comment
    • Parsing mode: advanced
    • Text to be parsed...:
    "Closed issues: " + toString(filterByFieldValue(linkedIssues("is Epic of", linkedIssues("has Epic")), %{00144}, =, "Done")) +
    "\nAll issues: " + toString(linkedIssues("is Epic of", linkedIssues("has Epic"))
    

    Share with me the comment you obtain.

  8. Steffen reporter

    Hi Fidel, in your code is an error and I'm not able to fix it. I tried the first part of the code to see "Closed Issues" but the comment is empty like: "Closed Issues: ............"

    Error.png

  9. Fidel Castro Armario repo owner

    Hi @Steffen1305,

    Use the following string expression:

    "Closed issues: " + toString(filterByFieldValue(linkedIssues("is Epic of", linkedIssues("has Epic")), %{00144}, =, "Done")) +
    "\nAll issues: " + toString(linkedIssues("is Epic of", linkedIssues("has Epic")))
    
  10. Fidel Castro Armario repo owner

    Hi @Steffen1305,

    You are not getting any issue at "Closed issues:". The only 2 reasons I can think of are:

    1. You don't have any issue child issue in a "Final" status. In that case, please, try again ensuring that you have a pair of issues in "Final" status. Share the comment again with me.
    2. You are not writing correctly the status category in your expression. In my expression I used "Done", but you should use exactly the name in your JIRA instance. You can check up the name of the status category at Administration > Issues > Statuses.
  11. Fidel Castro Armario repo owner

    Now, use that same status category in boolean expression at parameter "Filtering by field values:":

    count(filterByFieldValue(linkedIssues("is Epic of", ^%{00015}), %{00144}, =, "Done")) = count(linkedIssues("is Epic of", ^%{00015})) - 1
    
  12. Steffen reporter

    Thanks a lot for your Support!!! The Problem was the status category, again lost in translation

    Cheers, Steffen

  13. Log in to comment