Forums

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

How to use nunjucks to set a value in a field from the value of another field

Bruno Ramos December 2, 2020

In the post JMWE function of creating a new issue, how to define a field based on the value of another field? The fields and their values ​​are different, for example, if "field A" has the value 22 then set "field B" to "New York". Each field has more than 20 values.
JIRA Cloud.

1 answer

1 accepted

1 vote
Answer accepted
David Fischer
Community Champion
December 2, 2020

Hi Bruno,

you can add the field you want to set under the "Set fields of new issue" section, and then select, for that field, the "Set field value to:" option, and in the Value use a template that will return the desired calculated value. To map the values of one field to the desired values of the target field, a good approach is to use a "map":

{{ {
"22": "New York",
"23": "Dallas"
}[issue.fields.A.value] }}

(assuming field A is a single-select type custom field)

Bruno Ramos December 2, 2020

Thank you very much
worked perfectly!

Suggest an answer

Log in or Sign up to answer