Forums

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

JMWE: additional condition for calculating field values

Dmitry Kharishman January 7, 2022

How is it possible to build in an addtional condition for an event based "issue-field-value-changed"+"set-issue-field"-post function?

E.g.:

if the value of a field A is between 0 and 100, then set the value for filed B = 1,

if the value of a field A is between 100 and 200, then set the value for filed B = 2,

and so on

 

1 answer

0 votes
David Fischer
Community Champion
January 7, 2022

Hi @Dmitry Kharishman 

you don't need a condition for that - what you want is to use the Set Issue Fields post-function in the event-based action to set field B to a value calculated based on field A, using a Nunjucks expression. For example:

{% if issue.fields["A"] <= 100 %}
1
{% elif issue.fields["A"] <= 200 %}
2
{% else %}
3
{% endif %}
Dmitry Kharishman January 10, 2022

Hi David,

Thank you very much

Could you please support me with the format?

I would like to calculate the value for the field "Score" based on the formula below.

The dominator in the formula should become the values 1, 2, 3, 5 or 8 depending on the value for the field "Σ Original Estimate".

{{ (issue.fields["Business Value"] + issue.fields["Time Criticality"] + issue.fields["Risk Reduction"]) / ({% if issue.fields["Σ Original Estimate"] < 14400 %}
1
{% elif issue.fields["Σ Original Estimate"] < 28800 %}
2
{% elif issue.fields["Σ Original Estimate"] < 43200 %}
3
{% elif issue.fields["Σ Original Estimate"] < 72000 %}
4
{% elif issue.fields["Σ Original Estimate"] < 115200 %}
5
{% else %}
8
{% endif %}) }}

 

Many thanks

David Fischer
Community Champion
January 10, 2022

Hi @Dmitry Kharishman ,

try this:

{% if issue.fields["Σ Original Estimate"] < 14400 %}
{% set denom = 1 %}
{% elif issue.fields["Σ Original Estimate"] < 28800 %}

{% set denom = 2 %}
{% elif issue.fields["Σ Original Estimate"] < 43200 %}

{% set denom = 3 %}
{% elif issue.fields["Σ Original Estimate"] < 72000 %}
{% set denom = 4 %}
{% elif issue.fields["Σ Original Estimate"] < 115200 %}
{% set denom = 5 %}
{% else %}
{% set denom = 8 %}
{% endif %}
{{ (issue.fields["Business Value"] + issue.fields["Time Criticality"] + issue.fields["Risk Reduction"]) / denom }}
Dmitry Kharishman January 10, 2022

Thank you a lot. It works!

Suggest an answer

Log in or Sign up to answer