Forums

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

How to Use Nunjucks in Transition issue(s) Post-Function (JMWE) in JIRA CLOUD

Digvijay Singh Gehlot
Contributor
May 20, 2025

Hi Community,

My use-case is:

A Parent issue transitions from Open status to three different Statuses (Prioritized, Not-Prioritized, or Cancelled) based on it's Child Issues' statuses.

Per my configuration:

  • Parent issue (issuetype = Initiative) is present in Parent Project
  • Parent issue has three Children (issuetype = Portfolio Epic), present in three different Child Projects
  • All Children are linked to Parent via Parent Link, present on child screen. 
  • Parent should transition to next status based on Children statuses as below:
    • If all Children are transitioned to Cancelled status then Parent moves to Cancelled
    • If all Children are transitioned to Prioritized, then Parent moves to Prioritized
    • If all Children are transitioned to different statuses, then Parent moves to Not-Prioritized

I need help to run a logic using Nunjucks in Child Workflow - Transition issue(s) Post-Function under Advanced options > "Run this post-function only if a condition is verified" checkbox.

Any sample code or relevant help document on Nunjucks, will be a great help.

Thank you 

2 answers

Suggest an answer

Log in or Sign up to answer
0 votes
Paweł Mazur
Contributor
May 21, 2025

Hi, 

Thank you for your question! I’m Paweł, a Customer Success Manager here at Appfire. I'm happy to help.

In JMWE for Jira Cloud, you can use Nunjucks expressions in the "Transition issue(s)" post-function to automatically transition a parent issue based on the statuses of its child issues. Here’s a quick guide to get you started:

 1. Set Up the Event-based Action

  1. Go to Jira Settings → Apps

  2. Under Jira Misc Workflow Extensions, click Event-based Actions

  3. Click Create new action

  4. Name your action something like Auto-transition Initiative based on child statuses

  5. Under the WHEN section:

    • Event: Issue Transitioned

    • To Status: Choose specific statuses (e.g., Cancelled, Prioritized) or leave as Any

  6. Click Save

 2. Define the IF Scope

  • Issue Type: Portfolio Epic (child issue type)

  • Projects: Select the applicable projects or leave as Any for all projects

 3. Add the “Transition issue(s)” Post-function

  1. Under THEN, click Select Post-functions

  2. Choose Transition issue(s)

  3. In the configuration screen:

    • Target Issue: Parent issue of the current issue in the Portfolio hierarchy

    • Transition: Use the Transition Picker to select the workflow used by Initiatives, then choose:

      • Move to Cancelled → All children are Cancelled

      • Move to Prioritized → All children are Prioritized

      • Move to Not-Prioritized → Mixed statuses

  4. Under Advanced options, check:
    Run this post-function only if a condition is verified

Example Nunjucks Conditions

All children = "Cancelled"

{% set initiative = issue | initiative("key") %} 
{% if initiative %}
  {% set children = initiative | membersOfInitiative("status") %}
  {% set allCancelled = true %}
  {% for child in children %}
      {% if child.fields.status.name != "Cancelled" %}
          {% set allCancelled = false %}
      {% endif %}
  {% endfor %}
  {{ allCancelled }} 
{% else %}
  false 
{% endif %}

All children = "Prioritized"

{% set initiative = issue | initiative("key") %}
{% if initiative %}
    {% set children = initiative | membersOfInitiative("status") %}
    {% set allPrioritized = true %}
    {% for child in children %}
        {% if child.fields.status.name != "Prioritized" %}
            {% set allPrioritized = false %}
        {% endif %}
    {% endfor %}
    {{ allPrioritized }}
{% else %}
    false
{% endif %}

Mixed Statuses → Move Parent to "Not-Prioritized"

{% set initiative = issue | initiative("key") %}
{% if initiative %}
    {% set children = initiative | membersOfInitiative("status") %}
    {% set statusNames = children | map(attribute="fields.status.name") | unique %}
    {{ statusNames | length > 1 }}
{% else %}
    false
{% endif %}

For a detailed walkthrough on setting this up, check out our guide:
Move parent to Done when all child issues are closed

And if you have any questions or need a hand along the way, feel free to reach out through our support portal. We’re always happy to help!

Cheers,
Paweł Mazur
Customer Success Team | Appfire

Digvijay Singh Gehlot
Contributor
May 22, 2025

Hi @Paweł Mazur 

Thank you for your message and for providing the recommended solution.

What I observed is that;

  • Solution is working fine if I have only one transition between two statuses in Parent & Child Workflows i.e. from Approved to Prioritized only or from Approved to Cancelled only.

But in my scenario, there are three transitions coming out from Approved, to Prioritized, Not-Prioritized, and Cancelled.

When setting up the same configuration as mentioned above in:

  • Jira Misc Workflow Extension > Event-based actions

OR

  • directly adding Transition issue(s) post-function on individual transitions in the Child Workflow,
  • Parent is NOT transitioning to any of the next status, although Child(ren) moved to next statuses. 

Even, I am unable to find any Logs which may have recorded this mismatch action on Child Workflow.

Could you help me further why Parent is not transitioning when it's Child(ren) has moved to next status?

I would also like to share additional conditions in my mentioned use-case:

There is a Custom Field 1 on Child Screen which is a deciding factor if Child should go to Prioritized, Not-Prioritized, or Cancelled.

So, additional Conditions are:

  1. Parent should transition to Prioritized, if all those Child(ren) which have answered Yes in Custom Field 1 and moved to Prioritized (note: in this case, Parent will ignore other Child(ren) which have answered No/ None in Custom Field 1 and are moved to Not-Prioritized/ Cancelled)
    1. Eg: C1 = Yes & moved to Prioritized, C2 = No & moved to Not-Prioritized, C3 = None & moved to Cancelled, then P1 will move to Prioritized only.
  2. Parent should transition to Not-Prioritized, if all those Child(ren) which have answered No in Custom Field 1 and moved to Not-Prioritized, (note: If Child has answered NO in Customfield 1, then Child is Not allowed to transition to Prioritized; Parent will ignore other Child(ren) which have answered None and moved to Cancelled)
    1. Eg: C1 = No & moved to Not-Prioritized; C2 = No & moved to Not-Prioritized; C3 = None & moved to Cancelled, then Parent will move to Not-Prioritized only.
  3. Parent should transition to Cancelled, if all linked Child(ren) have set None in Customfield 1 and are moved to Cancelled.
    1. Eg: C1 = None & moved to Cancelled; C2 = None & moved to Cancelled; C3 = None & moved to Cancelled, then Parent will move to Cancelled only.

Please let me know if it is also possible via Nunjuck as I am able to run the Additional Conditions successfully using Groovy in Transition Issue Post-Function on all three transitions in Jira Data-Center.

Thanks

Digvijay Singh Gehlot
Contributor
May 22, 2025

I have the same workflow in Parent Project (Initiative) and multiple Child Projects (Portfolio Epic) as below:

IMG_20250522_170650.jpg

Digvijay Singh Gehlot
Contributor
May 22, 2025

Hi @Paweł Mazur 

I tested one simple scenario where if all the children have moved to Prioritized, then only Parent should move to Prioritized by using this code on Move to Prioritized transition on Child Workflow:

{% set initiative = issue | initiative("key") %}
{% if initiative %}
    {% set children = initiative | membersOfInitiative("status") %}
    {% set allPrioritized = true %}
    {% for child in children %}
        {% if child.fields.status.name != "Prioritized:" %}
            {% set allPrioritized = false %}
        {% endif %}
    {% endfor %}
    {{ allPrioritized }}
{% else %}
    false
{% endif %}

But Parent status didn't change when all the children have been moved to Prioritized

IMG_20250522_221625.jpg

Execution log is showing:

  • Message type: workflow-error
  • Message: Conditional Execution script does not look like a valid Nunjucks condition. Skipping execution. 

Please guide further, and looking forward to hearing from you soon. 

Thanks

Paweł Mazur
Contributor
May 23, 2025

Hi Digvijay,

Thank you for your detailed observations and for taking the time to test the solution. We're really glad to hear that it's working well in scenarios where there's only a single transition, such as Approved -> Prioritized.

I’d like to walk through your points and share some guidance on how to handle the more complex cases involving multiple transitions from the same status.

Your Observation
“The solution works fine with a single transition path but fails when multiple transitions are available from 'Approved'.”

Why this happens? 
When a parent issue (like an Initiative) has more than one possible transition from the same status, say from Approved to Prioritized, Not-Prioritized, or Cancelled, you’ll need to create a separate Event-based Action or Post-function for each transition. Each one should have clearly defined, non-overlapping conditions.

This ensures that only one condition evaluates to true at a time, allowing JMWE to execute the correct transition reliably.

Common Pitfall
If none of the conditions evaluate to true, JMWE doesn’t throw an error—it simply doesn’t run any post-function. This is expected behavior. JMWE logs execution errors, but it doesn’t log condition mismatches. So if a condition evaluates to false, that step is quietly skipped.

For troubleshooting
A helpful tip: try temporarily outputting values such as

{{ children | length }}

This can give you visibility into what’s being evaluated in your logic.

Your Updated Requirements
Here’s how I understand your intended logic using the custom field:

1. Transition to Prioritized
If all child issues with Custom Field 1 = Yes are in Prioritized
– Ignore children marked as No or left blank

2. Transition to Not-Prioritized
If all child issues with Custom Field 1 = No are in Not-Prioritized
– Ignore those marked as Yes or blank

3. Transition to Cancelled
If all child issues with Custom Field 1 left blank are in Cancelled
– Ignore those marked as Yes or No

Let me know if that matches your intent.

A few clarifying questions

  • Should the parent issue automatically move from Open to Approved before checking for these transitions? Based on your workflow, it looks like Prioritized, Not-Prioritized, and Cancelled all branch from Approved, so this step might be necessary.
  • What should happen if none of the child issues qualify for any of the transitions? Should the parent remain in Approved, or is there another fallback action you'd like to see?

Also, if possible, could you share the Groovy scripts you’ve implemented in Jira Data Center? This would really help us validate and fine-tune the setup on our side.

Regarding the other error you encountered, we strongly recommend reaching out to us through our Support portal  We’re diving pretty deep into the specifics of your setup, and we’d really prefer to continue the conversation in a space where we don’t need to share unnecessary logs or potentially sensitive information. It also allows us to loop in other JMWE team members and collaborate more effectively. It’s a much better environment for this kind of troubleshooting than a public forum.

Looking forward to your insights.

Kind regards,
Paweł Mazur
Customer Success Manager, Appfire

Digvijay Singh Gehlot
Contributor
May 23, 2025

Hi @Paweł Mazur 

Thank you so much for your message and I would like to share the below details:

Should the parent issue automatically move from Open to Approved before checking for these transitions? Based on your workflow, it looks like Prioritized, Not-Prioritized, and Cancelled all branch from Approved, so this step might be necessary.

  • In Parent & Child workflows, Parent and Child(ren) are manually moved from Open to Approved.
  • On Approved status, find the Child actions below:
    • If Custom field is answered Yes on Child, it is only allowed to move to Prioritized or Cancelled.
    • If Custom field is answered No on Child, it is only allowed to move to Not-Prioritized or Cancelled.
    • If Custom field is kept as None on Child, it is only allowed to move to Cancelled.
  • From Approved to Prioritized, Not-Prioritized, or Cancelled - find the Parent action below:

Parent should move to Not-Prioritized based on below:

C1 > C2 > C3 > P1

1) Not-Prioritized > Not-Prioritized > Not-Prioritized > Not-Prioritized
2) Not-Prioritized > Not-Prioritized > Cancelled > Not-Prioritized
3) Not-Prioritized > Cancelled > Not-Prioritized > Not-Prioritized
4) Cancelled > Not-Prioritized > Not-Prioritized > Not-Prioritized
5) Cancelled > Cancelled > Not-Prioritized > Not-Prioritized
6) Cancelled > Not-Prioritized > Cancelled > Not-Prioritized
7) Not-Prioritized > Cancelled > Cancelled > Not-Prioritized

Parent should move to Cancelled based on below:

C1 > C2 > C3 > P1 
1) Cancelled > Cancelled > Cancelled > Cancelled

Rest on all other Child(ren) conditions, Parent should transition to Prioritized

 

What should happen if none of the child issues qualify for any of the transitions? Should the parent remain in Approved, or is there another fallback action you'd like to see?

  • Parent should only move from Approved to the next status, when NO child is in Approved AND all Children are transitioned to next status
  • i.e. when the every last child moved to next status, Parent should check all the linked Children statuses, and then Parent should move to appropriate status OR Parent will remain in Approved.
  • Even, I am using Linked Issue Status Conditions from Approved to Prioritized, Not-Prioritized, or Cancelled on Parent Workflow to make a successful transition of Parent based on above Children status Conditions.

First C1 Moved > Second C2 Moved > Third C3 Moved > Then P1 Moves
1) Prioritized > Prioritized > Prioritized > Prioritized
2) Cancelled > Prioritized > Not-Prioritized > Prioritized
3) Not-Prioritized > Cancelled > Not-Prioritized > Not-Prioritized
4) Prioritized > Not-Prioritized > Approved (C3 didn't move) > No Parent Transition

Regarding Groovy script: 

I am running multiple if-elseif-else conditions of Children statuses on each Transitions from Approved to Prioritized, Not-Prioritized and Cancelled on Child Workflow. It will be hard to write here, I'll share the complex code in the Support Ticket.

However, I am still want basic/ sample code using Nunjucks which can satisfy the above use-case as I want to build if-elseif-else concept around it and will share the same with your team if I am stuck somewhere.

May you guide me further? 

Thanks

0 votes
Digvijay Singh Gehlot
Contributor
May 20, 2025

Hi @Suprija Sirikonda _Appfire_ 

May you guide me with my above use-case on how can I achieve the same using nunjuck in transition issue post function? As I am new to Nunjuck functionality. 

Thanks in advance. 

TAGS
AUG Leaders

Atlassian Community Events