Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Transition "Parent" based on "Children" progress using JMWE Transition linked issues post-function

Séverin MAZOUNIE February 10, 2019

Hello, 

 

I'm having troubles getting my "Transition linked issues" post-function to properly work.
Here is what I intend to do: 

 

Setup:

  • Jira Cloud + JMWE
  • 2 sets of Projects:
    • One "Head" project in which users log all their requests/bugs
    • X "System" projects (one per system) in which developers resolve them
  • A custom Link type added to the usual Duplicates, Cloners, Blockers, Relates, with:
    • Inward link name: "is child of"
    • Outward link name: "is parent of"
  • 2 similar linear workflows for both Head and System projects with the same sequential steps:
    • 1 - To Do
    • 2 - In Progress
    • 3 - Done
    • 4 - Closed

 

Use Case: 

A user logs a (parent) issue in the "Head" project that impacts let's say systems A, B and C. (child) Issues are automatically created in the "System" projects A, B and C and are linked to the (parent) issue in the "Head" project with the above custom link type (This works like a charm thanks to JMWE!).

Hence, we end up with 4 issues in 4 different projects:

  • 1 in the "Head" project that "is parent of" the 3 others
  • 1 in each of the "System" projects that each "is child of" the one in the "Head" project

Now I want to automate the "parent" issue transitioning from "To Do" to "In Progress" when AT LEAST ONE of its "child" issues reaches workflow step 2 (In Progress), and from "In Progress" to "Done" when ALL (the last) of its "children" reach workflow step 3 (Done) - knowing that at that time one or more of these issues might already be in step 4 (Closed).

 

My first (unsuccessful) try at this: 

Not knowing how to tackle the AT LEAST ONE case, I started with the ALL case that benefit from a closely related documented setup (Epic/Stories transitioning):

  • Added the "Transition linked issues" post-function to the transition leading to the "Done" status in the "System" projects workflow
  • Input the transition name of the "In Progress" to "Done" transition from the "Head" project workflow
  • Selected the "is child of" link type (child to parent relationship)
  • Checked the Conditional execution check box
  • Wrote the following script in the Condition section:

{% set children = issue | linkedIssue | linkedIssues("is parent of") %}
{% set trigger = true %}
{% for child in children %}
      {% if child.fields.status.name != "Done" %}
            {% set trigger = false %}
      {% endif %}
{% endfor %}
{{ trigger }}

  • Placed this post-function at the end of the post-functions list

 

>> I gave it several tries and... nothing happens at the Parent issue-level.

  • Tried without the condition and it works as expected (the right transition is triggered on the right linked issue), so no problem in the basic setup
  • Tried with a 5, 10 and 15s delay just in case > same (absence of) result
  • Looked at the JMWE Logs: no errors returned, only the "post-function-triggered" and "post-function-success" info

 

First off, has anyone an idea of what I'm doing wrong here / already tried this / know how to make it work? Second, does someone know how to adapt it to the AT LEAST ONE case? 

Many thanks in advance to whomever will take the time to help me on this! 

 

Best, 

Severin

1 answer

1 accepted

0 votes
Answer accepted
David Fischer
Community Champion
February 13, 2019

Hi Severin,

There is a small error in your conditional execution script. It should be:

{% set children = linkedIssue | linkedIssues("is parent of") %}
{% set trigger = true %}
{% for child in children %}
      {% if child.fields.status.name != "Done" %}
            {% set trigger = false %}
      {% endif %}
{% endfor %}
{{ trigger }}

You should also add a small (2-second) delay to the post-function to make sure the current "child" issue is done transitioning to Done.

 

As for the "at least one" use case, you don't need any condition, since the transition linked issues post-function will be on the "start progress" transition of the child issue, so at least that chile issue is guaranteed to be "in progress" by the time the transition linked issues post-function runs. Also, if the parent issue is not in the To Do status, the "start progress" transition won't be available so the transition linked issues post-function will do nothing.

Séverin MAZOUNIE February 15, 2019

Hello David,

Works perfectly with your correction! I couldn't have spotted it! Thank you very much! Nunjucks syntax and logic do not always appear very straightforward to me.. 

As for the "at least one" use case that's also what I thought but I was worried to flood the logs with warnings/errors because of JMWE not finding the transition available.. I added a basic condition to not trigger if the parent is already in the desired state, just for the sake of keeping it clean..

Thanks again!

Severin

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events