How would one create multiple tables with unique JQL search when sending an email through automation
Asked by Zach:

I am trying to create an automation that will send an email out that contains multiple tables in it.   

For example I want to gather the total number of tickets created in the specified project within the last 24 hours and from that data I would like to be able to create multiple tables based on specific values/fields contained with in those tickets

I already have an automation set up to perform a look up and report out all tickets in an email but the granularity of the tables is what I am struggling with

<br />

I am working with Jira Server

Example of what I would like the results to look like:

![MultiTables.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/321646i36A1B8ED48561D81/image-size/large?v=v2&px=999 "MultiTables.PNG")


Answers:
author: Kalyan Sattaluri
body: Hello [@Zach](/t5/user/viewprofilepage/user-id/5488954)

Welcome to the community..

You need to use list [iteration](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-lists/#:~:text=Story%20Points.sum%7D%7D-,Combined%20function%20examples,-Iterates%20over%20the) and [conditional statements](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-conditional-logic/) to make it work..

I havent tested below syntax, but this is how I usually solve it.. Notice the bolded part, thats how you you can filter each block of your table.

\<table border='1' style='border-collapse:collapse'\>  
\<tr\>  
\<th\>Issue Type\</th\>  
\<th\>Key\</th\>  
\<th\> Status \</th\>  
\<th\>Summary\</th\>  
\</tr\>  
\<tr\>  
**{{#issues}}{{#if(equals(status.name, "Done"))}}**  
\<td\> {{issueType.name}}\</td\>  
\<td\>\<a href="{{toUrl}}"\>{{key}} \</a\>\</td\>  
\<td\>{{status.name}} \</td\>  
\<td\> {{Summary}} \</td\>  
\</tr\>  
{{/}}  
{{/}}  
\</table\>  
Hope it helps.

comments: author: Kalyan Sattaluri
body: Below will be the criteria in your case for example:

{{#issues}}{{#if(equals(issueType.name, "Type A"))}}


author: Zach
body: Here is what i have an its populating an error "*Error rendering smart-values when executing this rule:* "  

\<h3\>\<h3\>Daily New Issue Report\</h3\>

\<p\>\<b\>Total Tickets\</b\>: {{lookupIssues.size}}\</p\>

\<p\>\<b\>Type A Tickets \</b\>\</p\>  
\<style\>  
table {border-collapse:collapse;}  
table, td, th {border:1px solid black;}  
table, td, th {font-family: calibri;}  
th {background-color: rgb(217,217,217);color:black}  
table, td {font-size:90%;height: 25px}  
th {font-size:95%;}  
td {text-align:center}  
\</style\>

\<table border="1"\>  
\<tr\>  
\<th style="width:100px"\>Key\</th\>  
\<th style="width:150px"\>Issue Type\</th\>  
\<th style="width:150px"\>Reporter\</th\>  
\<th style="width:1000px"\>Summary\</th\>  
\</tr\>**{{#lookupIssues}}{{#if(equals(issueType.name, "Type A"))}}**   
\<tr\>  
\<td\>\<a href="{{url}}"\>{{Key}}\</a\>\</td\>  
\<td\>{{fields.issuetype.name}}\</td\>  
\<td\>{{reporter.displayName}}\</td\>  
\<td\>{{summary}}\</td\>  
\</tr\>  
{{/}}\</table\>

\<p\>\<b\>Type B Tickets \</b\>\</p\>  
\<table border="1"\>  
\<tr\>  
\<th style="width:100px"\>Key\</th\>  
\<th style="width:150px"\>Issue Type\</th\>  
\<th style="width:150px"\>Reporter\</th\>  
\<th style="width:1000px"\>Summary\</th\>  
\</tr\>**{{#lookupIssues}}{{#if(equals(issueType.name, "Type B"))}}**   
\<tr\>  
\<td\>\<a href="{{url}}"\>{{Key}}\</a\>\</td\>  
\<td\>{{fields.issuetype.name}}\</td\>  
\<td\>{{reporter.displayName}}\</td\>  
\<td\>{{summary}}\</td\>  
\</tr\>  
{{/}}\</table\>


author: Kalyan Sattaluri
body: Hello [@Zach](/t5/user/viewprofilepage/user-id/5488954)

Couple of things:

lookupIssues in Server/Data Center does not expose all fields. In my test, issuetype.name is one of them. So you need to confirm that all the fields you want are available by logging them before using them in your email. If you are not able to log {{lookupIssues.issueType.name}} you are limited to using JQL in the scheduled trigger and reference {{issues}} from that results instead of lookup.

Second is that, you are missing closing tags in each block.. (highlighted)

\<table border="1"\>  
\<tr\>  
\<th style="width:100px"\>Key\</th\>  
\<th style="width:150px"\>Issue Type\</th\>  
\<th style="width:150px"\>Reporter\</th\>  
\<th style="width:1000px"\>Summary\</th\>  
\</tr\>  
\<tr\> {{#issues}}{{#if(equals(issueType.name, "Story"))}}  
\<td\>\<a href="{{url}}"\>{{Key}}\</a\>\</td\>  
\<td\>{{fields.issuetype.name}}\</td\>  
\<td\>{{reporter.displayName}}\</td\>  
\<td\>{{summary}}\</td\>  
\</tr\>  
{{/}}**{{/}}**\</table\>


author: Zach
body: Ok, yeah i scrapped the lookup action, switched to a scheduled jql and added the closing tag. It started to produce the results I'm looking for. I was able to create 2 tables that are unique based on issue type. I just need to finish cleaning it up so it displays how i want. Thank you for your help!