JMWE Cant set issue field although tester gives result

Aslıhan Paksoy December 23, 2021

Hi everyone,

I want to write a event-based action. Let me give some detail.

A is linked to B through relates to. C is the sub-task of the B. When a x field changes in C, I want to sum all x fields in B's subtasks and write the result a y field of A.

A

     B

      C

 

Although tester gives me the right result, it does not reflect on A's y field. What am I missing?

Thanks,

Below the details of my event based action;event.png

1 answer

1 accepted

0 votes
Answer accepted
David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 23, 2021

Hi @Aslıhan Paksoy 

the biggest issue is with the Value Nunjucks template for the Set Issue Fields post function:

  1. the parentIssue variable is not available in this context
  2. since you have configured Target issues ("Issue(s) to operate on"), the Nunjucks template is evaluated for each target issue, and the target issue is available in the targetIssue variable. The Nunjucks template must therefore iterate over each linked issue, and then over each sub-task of the linked issue(s).

The right Nunjucks expression is:

{% set total = 0 %}
{% for linkedIssue in targetIssue | linkedIssues("relates to", ["subtasks"]) %}
{%set total = total + (linkedIssue | subtasks("customfield_10205") | field("fields.customfield_10205") | sum) %}
{% endfor %}
{{ total }}

You might also want to select your sub-task issue type(s) in the "Scope" section, for better performance.

Aslıhan Paksoy December 26, 2021

This is excellent!It works, thank you so much 

Suggest an answer

Log in or Sign up to answer