Set a validation on number of subtask in certain status

Issue #153 resolved
TiN created an issue

Hello, I would like to know, how to set a validation on number of subtask in certain status. for example: I have a simple workflow: to do <-> in progress <-> done . If all subtasks are done, then the parent issue is done. Now i restart a subtask by moving it from "done" to "in progress", parent status should also change to "in progress" as i use "copy a parsed text" to parent's issue status then i move another subtask in "to do", the parent's status should not changed in "to do" because of a subtask "in progress" --> this is the valdidation i want to set.

i hope you understand what i mean :) best regards TA

Comments (17)

  1. Fidel Castro Armario repo owner

    To prevent parent issue from being transitioned to "Done" status while there still are subtasks at "To Do" or "In Progress" statuses, you should insert "Validation on subtasks" into "Done" transition of parent issue's workflow using the following configuration:

    conf-0.png conf-1.png conf-2.png conf-3.png

    Once configured, transition "Done" parent's issue workflow will look like this:

    conf-4.png

    This configuration also works if you share the same workflow with parent issue and subtasks.

    VERY IMPORTANT: Due to the introduction of the validation, you should edit the configuration of "Copy a parsed to a field" post-function and replace target field "Parent's issue status" with "Parent's issue status (delayed writing)".

  2. TiN reporter

    I think you misunderstand me.

    What i meant is, trasition the parent issue status under condition of number subtask "in progress"

    for example:

    • the parent issue A and all subtasks A1,A2,A3... are done --> all statuses "Done"

    • reopen 1 subtask A1 by moving A1 back "to do" --> now parent issue A status "to do"

    • restart 1 subtask A2 by moving A2 back "in progress" --> now parent issue A status "in progress"

    • reopen 1 subtask A3 by moving A3 back "to do" --> parent issue A status should stay "in progress"

    because we have subtask A2 "in progress"

    so the condition should be:

    if there is no subtask "in progress, then the parent issue status could be changed into "to do"

    else the parent issue status must stay "in progress"

  3. Fidel Castro Armario repo owner

    Sorry, for my misunderstanding.

    Anyway, the validation I explained you in my previous post should be inserted in all transitions having "Done" as target status in parent issue's workflow.

    Additionally you should insert "Validation on subtasks" into all transition with "To Do" as target status in parent issue's workflow, using the following configuration:

    conf-0.png conf-1.png conf-2.png conf-3.png

    Once configured, transitions with "To Do" as target status will look like this:

    conf-10.png

    Additionally to that validation you should insert "Copy a parsed text to a field" post-function to the the following 3 transitions of subtask's workflow with the corresponding configurations:

    1) Transition To Do as target status:

    • Target field: Parent's issue status (delayed writing)
    • Parsing mode: basic
    • Text to be parsed: To Do

    2) Transition In Progress as target status:

    • Target field: Parent's issue status (delayed writing)
    • Parsing mode: basic
    • Text to be parsed: In Progress

    3) Transition Done as target status:

    • Target field: Parent's issue status (delayed writing)
    • Parsing mode: basic
    • Text to be parsed: Done

    Regards.

  4. TiN reporter

    Thank you.

    I have another question about transition by using "Set a field as a function of other fields".

    if the current status is "Done",then change the status of parent issue in "To Do", else "In Progress".

    What I have tried:

    The field Parent's issue status (delayed writing) will be set according to the evaluation of Summary against the following set of rules:

    [%{Previous issue status}="IN PROGRESS"]"IN PROGRESS"

    [%{Previous issue status}="DONE"]"TO DO"

    This feature will be run as Current user.

    It is not the correct syntax, isn't it?

  5. Fidel Castro Armario repo owner

    Hi TA,

    I don't know exactly what you intend to do, but I can tell you that syntax is not correct for two reasons:

    • You should write the names of the statuses exactly as they are. Beware that recent versions of JIRA always show the statuses in UI changed to upper case. You can consult the real name at "Administration > Issue > Statuses". Please, don't confuse issue status with status category. There are also available virtual fields "Issue status category" (%{00144}) and "Previous issue status category" (%{00146}), just in case you need any of them.

    • You shouldn't use double quotes in the value part of your setting rules, since it's parsed in basic mode, unless you add prefix 'a' to your setting rules, which will inform that the value part should be parsed in advanced mode.

    A valid configuration is shown in the following screenshot:

    conf-1.png

    Note that:

    • [%{00138} is field code for "Previous issue status".
    • I'm supposing that you have two statuses called "In Progress" and "To Do".
  6. TiN reporter

    Thank you very much. Just one question more :)

    what syntax mistake i have made with the following function:

    The field Parent's issue status (delayed writing) will be set according to the evaluation of Summary against the following set of rules:

    [%{00027}[%{00016} = "IN PROGRESS"] = 0]TO DO

    [%{00027}[%{00016} = "IN PROGRESS"] > 0]IN PROGRESS

    What i want to do is checking/counting the number of subtask with the status "In Progress".

    • {00027} is number of subtasks.
    • {00016} is issue status.
    • If there is no subtask "In Progress", then change the parent status to "To Do".
    • If there is at least 1 subtask "In Progress", then the parent status should stay "In Progress".
  7. Fidel Castro Armario repo owner

    The problem is that you should write a valid boolean expression between [ ]. Correct setting rules are:

    [count(filterByStatus(subtasks(), "In Progress")) = 0]To Do

    [count(filterByStatus(subtasks(), "In Progress")) > 0]In Progress

    Here we are getting the subtasks using subtasks(), then we filter them by status using filterByStatus(issues, statuses), and then we count them using count(issues).

  8. TiN reporter

    Thanks again

    EDIT:

    Eventhough there are still 2 subtasks "In Progress", moving 1 subtask from "In Progress" to "To Do" still changes the parent issue status into "To Do".

    Parent status should stay "In Progress", because there is still 1 subtask "In Progress"

    Sorry that I am so annoying but I don't know what failure I make :(

  9. Fidel Castro Armario repo owner

    Sorry, you should use subtasks(%{00041}) instead of subtasks() since, you want to get the subtasks of parent issue, not current issue (which in your case is a subtask).

    Use the following setting rules instead:

    [count(filterByStatus(subtasks(%{00041}), "In Progress")) - 1 = 0]To Do

    [count(filterByStatus(subtasks(%{00041}), "In Progress")) - 1 > 0]In Progress

    Note that %{00041} is field code for "Parent's issue key".

    I decrement the returned number since I suppose that I should discount current subtask.

  10. Log in to comment