I'm using Automation on Jira Cloud to generate a Release email once a version is released. I've used Lookup Up Issues action using JQL against the version id, which works fine. I then log the value {{lookupIssues.size}} to confirm that this smart value returns a number, which it does in the audit log. I then want to use that value within the email content, but instead of returning the number of tickets being released, it duplicates the line of text for the amount of times of the smart value.
My code within the email is:
Hot Fix {{version.name}} included these items:
{{#lookupIssues}}
Total number of items released: {{lookupIssues.size}}
{{/lookupIssues}}
The output in the email is:
Hot Fix <version name. included these items:
Total number of items released:
Total number of items released:
Total number of items released:
Total number of items released:
Total number of items released:
Total number of items released:
Total number of items released:
Total number of items released:
Total number of items released:
Total number of items released:
Total number of items released:
Total number of items released:
Total number of items released:
Total number of items released:
The audit log value is: 14 and as you can see 14 rows are duplicated above.
The full email code is:
Hot Fix {{version.name}} included these items:
{{#lookupIssues}}
Total number of items released: {{lookupIssues.size}}
{{/lookupIssues}}
Stories
=======================================
<ul>
{{#lookupIssues}}
{{#if(equals(issuetype.name,"Story"))}}
<li><a href="{{url}}">{{key}}</a>: {{issuetype.name}}: {{summary}}</li>{{/}}
{{/lookupIssues}}
</ul>
Bugs
=======================================
<ul>
{{#lookupIssues}}
{{#if(equals(issuetype.name,"Bug"))}}
<li><a href="{{url}}">{{key}}</a>: {{issuetype.name}}: {{summary}}</li>{{/}}
{{/lookupIssues}}
</ul>
Tasks
=======================================
<ul>
{{#lookupIssues}}
{{#if(equals(issuetype.name,"Task"))}}
<li><a href="{{url}}">{{key}}</a>: {{issuetype.name}}: {{summary}}</li>{{/}}
{{/lookupIssues}}
</ul>
Hi @Mashford, Reuben and welcome to the community
I guess you´d like to have this line only once. As {{#lookupIssues}} is iterating through the list of issues delivered by the JQL it repeats the line (as it tries to write anything per issue).
Try to just use the following line:
Total number of items released: {{lookupIssues.size}}
Best
Stefan
Hi @Stefan Salzl thanks for the welcome.
I did originally have the above in my code, but got an error around closing lookupissues tag, but I think that was related to the per issue type blocks, which is why they now all open and close the lookupissues tag, so probably inadvertently changed it thinking it was failing as the logs don't show resolved smart variables.
I did find it odd that the value wasn't written in my above scenario but instead the code previous was iterated that number of times.
I will let you know once I've been able to test again to confirm resolution.
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.