Automation lookup issue with split result by email

Joseph Hani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 22, 2024

Hello Atlassian Community,

I'm trying to set up a Jira automation rule to send email notifications using lookup issues. But I want my email to have a condition that show two different results into the same email

- If issue priority is "High" and last comment is 5 days ago from now 

- If issue priority is "Critical" and last comment was 2 days ago 

However, I'm facing an issue where the email is being sent successfully (with no error..), but it doesn't display any issues.

I think I'm missing something using the "if condition" from this documentation : 

https://support.atlassian.com/cloud-automation/docs/jira-smart-values-conditional-logic/

I found this community post and tried to do the same thing : 

https://community.atlassian.com/t5/Jira-Software-questions/Jira-Automation-smart-value-list-for-Parent-items-in-Sprint/qaq-p/2583478

Here is the code i'm trying to make it work and in bold the event I want to do 


<p>Hello!</p>
<p> Automated Emails <br> </p>

<h3>High Priority Issues</h3>

<br>
<table style="border-collapse: collapse">
<thead>
<tr style="border:1px solid #e28743; background-color: #e28743">
<th style="border:1px solid #e28743; text-align:center; vertical-align:center; padding:15px 0px 15px 0px; width:120px">Issue Key</th>
<th style="border:1px solid #e28743; text-align:center; vertical-align:center; padding:15px 0px 15px 0px">Summary</th>
<th style="border:1px solid #e28743; text-align:center; vertical-align:center; padding:15px 0px 15px 0px">Priority</th>
<th style="border:1px solid #e28743; text-align:center; vertical-align:center; padding:15px 0px 15px 0px">Created Date</th>
</tr>
</thead>

<tbody>
{{#lookupIssues}}
{{#if(and(equals(issue.priority.name."High / Critical"), issue.comments.last().created.isBefore(now().minusDays(5))))}}
<tr>
<td style="border:1px solid #e28743; text-align:left; vertical-align:top"> <a href={{url}}> {{key}} </a> </td>
<td style="border:1px solid #e28743; text-align:left; vertical-align:top"> {{summary}} </td>
<td style="border:1px solid #e28743; text-align:left;vertical-align:top"> {{priority.name}} </td>
<td style="border:1px solid #e28743; text-align:left;vertical-align:top"> {{created.jiraDate}} </td>
</tr>
{{/}}{{/}}</tbody>

</table>

<h3>Critical Priority Issues</h3>

<br>
<table style="border-collapse: collapse">
<thead>
<tr style="border:1px solid #e28743; background-color: #e28743">
<th style="border:1px solid #e28743; text-align:center; vertical-align:center; padding:15px 0px 15px 0px; width:120px">Issue Key</th>
<th style="border:1px solid #e28743; text-align:center; vertical-align:center; padding:15px 0px 15px 0px">Summary</th>
<th style="border:1px solid #e28743; text-align:center; vertical-align:center; padding:15px 0px 15px 0px">Priority</th>
<th style="border:1px solid #e28743; text-align:center; vertical-align:center; padding:15px 0px 15px 0px">Created Date</th>
</tr>
</thead>

<tbody>
{{#lookupIssues}}
{{#if(and(equals(issue.priority.name."Highest / Blocker"), issue.comments.last().created.isBefore(now().minusDays(2))))}}
<tr>
<td style="border:1px solid #e28743; text-align:left; vertical-align:top"> <a href={{url}}> {{key}} </a> </td>
<td style="border:1px solid #e28743; text-align:left; vertical-align:top"> {{summary}} </td>
<td style="border:1px solid #e28743; text-align:left;vertical-align:top"> {{priority.name}} </td>
<td style="border:1px solid #e28743; text-align:left;vertical-align:top"> {{created.jiraDate}} </td>
</tr>
{{/}}{{/}}</tbody>

</table>

If you have any idea on how I can resolve this issue ! 

Thank you very much for your help ! 

Have a nice day ! 

2 answers

1 accepted

2 votes
Answer accepted
Kalyan Sattaluri
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 22, 2024

Hello @Joseph Hani 

Seems like you have few issues with your syntax:

Log below value and see if you are seeing "Condition Passed" as out put if all checks are passed.

{{#lookupIssues}} {{#if(and(equals(priority.name, "High / Critical"), comments.last.created.isBefore(now.minusDays(5))))}} Condition passed {{/}}{{/}}

And then implement it in your email:

image.png

Hope it helps.

Joseph Hani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 22, 2024

Hello @Kalyan Sattaluri 

Thank you very much for your answer ! You right my syntax was wrong I forgot to not use "issue" when i'm using lookup ... 

Now it is perfect ! :D 

Like # people like this
Joanna Pietruszka
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 4, 2024

Hi @Joseph Hani  I have the similiar use case. Could you share the final code that you used to achieve lookup issue with split result (2 tables) by email?

0 votes
Joseph Hani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 22, 2024

See answer below 

Suggest an answer

Log in or Sign up to answer