JMWE Cloud: Why does my script evaluating multiple Nunjucks variables in multiple code blocks not work correctly?
Problem
Users often find that their scripts evaluating multiple values in Nunjucks either return incorrect results or have script errors.
These scripts are found to include multiple {{ }} code blocks with additional “code” in between them. For example, the below scripts are incorrect:
{{ issue.fields.summary }} + " - " + {{ issue.fields.description }}{{ issue.fields.customfield_12345.value }} == {{ issue.fields.customfield_67890.value }}Solution
Any text in a Nunjucks script outside a {{ }} code block will be output as is. Using the two code snippets above, the following would be a sample output returned:
Issue Summary + " - " + Issue Descriptioninstead ofIssue Summary - Issue DescriptionOption 3 == Option 3instead oftrue
To resolve this problem, ensure that all code is enclosed within {{ }} code blocks and that only hardcoded strings exist externally from code blocks. The corrected versions of the script snippets above are:
{{ issue.fields.summary + " - " + issue.fields.description }}{{ issue.fields.customfield_12345.value == issue.fields.customfield_67890.value }}