Automation: Custom Fields - Lookup issues not working
Asked by Melissa C:

Hello,

I've been using Project Automation for some time, I'm able to send emails using the following (See Below) - We recently got a Jira update and now have the "Lookup Issues" when I compile my automation and apply the name smart values (using {{issues}}) I can not get the custom fields. I'm only able to get Key with an url, Summary, Assignee.

Is this a limitation of the "lookup Issues" feature?

We use Jira Data Center

\<tr\>  
\<td\>  
\<a href="{{epic link.url}}"\>{{epic link.epic name}}\</a\> \</td\>  
\<td\>{{Key}} \</td\>  
\<td\>{{summary}}\</td\>  
\<td\>\<a href="{{epic link.Document Link}}"\>{{epic link.epic name}}\</a\>\<br\>  
\</td\>  
\<td\>{{customField_11726}}\</td\>  
\<td\>{{Assignee.displayName}}\</td\>  
\<td\>{{Teams Impacted}}\</td\>  
\<td\>{{Product Line}}\</td\>  
\<td\>{{Updated.shortDate}}\</td\>  
\</tr\>


Answers:
author: Bill Sheboy
body: Hi [@Melissa C](/t5/user/viewprofilepage/user-id/474554)

Unfortunately, the Lookup Issues action for Jira Data Center version does not support most fields yet, including custom fields: <https://jira.atlassian.com/browse/JIRAAUTOSERVER-877>

If it is of any consolation, when Lookup Issues was first added for Jira Cloud, it also only had about a dozen fields, and a year later all of the others were added. So I recommend watching that suggestion to see any progress.

There are two possible workarounds, depending upon what you need to accomplish and your rule structure:

* When you need the fields for a message / email, and are not already using a branch
  * Please try the bulk-handling feature of branches, using the {{issues}} (note that one is plural) in place of {{lookupIssues}}
  * Please look here to learn more: <https://confluence.atlassian.com/automation/run-a-rule-against-issues-in-bulk-993924653.html>
* When you need to sum, average, etc. fields to update another issue
  * Using the Send Web Request action, call a REST API function to search for the issues with JQL, and process the response in place of the lookup results
  * If you want to try that approach, here is a how-to article for calling a REST API function from a rule and the function I believe is needed:
    * <https://community.atlassian.com/t5/Jira-Software-articles/Automation-for-Jira-Send-web-request-using-Jira-REST-API/ba-p/1443828>
    * <https://docs.atlassian.com/software/jira/docs/api/REST/9.13.0/#api/2/search-search>

Kind regards,  
Bill

comments: author: Melissa C
body: Thanks [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313)

So disappointing!!! But I'll keep my hopes up!!

What I wanted to do was supper simple, just wanted to email a weekly report that consists of two different tables. Currently I'm running to rules and them combine them in outlook and send it as one.


author: Bill Sheboy
body: From your response I am guessing you are using Jira Data Center, correct?

Are your two different tables over the same issue set or different sets?


author: Melissa C
body: [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313)

Yes, Data Center

So two tables similar issue set

1st table Epics approved in the last week

2nd table Task closed in the last week

We just got this new upgrade this was so exciting!


author: Bill Sheboy
body: Thanks, and to have those two tables handled by a single rule, it could:

* use a Send Web Request action to call the REST API issue search for the first table
* preformat the HTML and save the results with a Create Variable action
* use a second Send Web Request to get the results for the second table
* send the email, including the preformatted variable and the second results


author: Kalyan Sattaluri
body: Hello [@Melissa C](/t5/user/viewprofilepage/user-id/474554)

Other than Bill's suggestion, another option is to filter your result set on the fly as needed.

Start with your scheduled trigger where you have {{issues}} which is your complete result set.

Then you can create your tables like below..

Please note the If checks are case sensitive. so Epics != epics. You have to use the right case for checks to pass. Which you can find by logging sample values from an issue.

--------------------------------------------

**TABLE 1:**

*\<table border="1"\>*   
*\<tr\>*   
*\<th style="width:100px"\>Key\</th\>*   
*\<th style="width:150px"\>Issue Type\</th\>*   
*\<th style="width:150px"\>Assignee\</th\>*   
*\<th style="width:150px"\>Reporter\</th\>*   
*\<th style="width:1000px"\>Summary\</th\>*   
*\</tr\>*

{{#Issues}}

**{{#if(or(equals(issueType.name, "Epics"),equals(status.name, "Approved")))}}**   
\<tr\>  
\<td\>\<a href="{{url}}"\>{{Key}}\</a\>\</td\>  
\<td\>{{fields.issuetype.name}}\</td\>  
\<td\>{{assignee.displayName}}\</td\>  
\<td\>{{reporter.displayName}}\</td\>  
\<td\>{{summary}}\</td\>  
\</tr\>  
{{/}}

**{{/}}**\</table\>

-------------------------------------

**TABLE 2:**

*\<table border="1"\>*   
*\<tr\>*   
*\<th style="width:100px"\>Key\</th\>*   
*\<th style="width:150px"\>Issue Type\</th\>*   
*\<th style="width:150px"\>Assignee\</th\>*   
*\<th style="width:150px"\>Reporter\</th\>*   
*\<th style="width:1000px"\>Summary\</th\>*   
*\</tr\>*

{{#Issues}}

**{{#if(or(equals(issueType.name, "Tasks"),equals(status.name, "Closed")))}}**   
\<tr\>  
\<td\>\<a href="{{url}}"\>{{Key}}\</a\>\</td\>  
\<td\>{{fields.issuetype.name}}\</td\>  
\<td\>{{assignee.displayName}}\</td\>  
\<td\>{{reporter.displayName}}\</td\>  
\<td\>{{summary}}\</td\>  
\</tr\>  
{{/}}

**{{/}}**\</table\>

------------------------------------------------

NOTE, I suggest you do an If check with JQL before sending email so you dont send empty emails out. so your rule could look like:

* Trigger = Scheduled with your current JQL criteria
* Add component -\> If/Else condition -\> JQL check =\> issuetype = Epics and status = approved
* Action send email with Table 1
* Else -\> JQL check =\> issuetype = Task and status= closed
* Action send email with Table 2

Or, you can send 1 email with both tables but still do the If check by combining the JQL, that way, as I said, you dont send blank emails.

Refer to recent discussion on similar requirement below:

<https://community.atlassian.com/t5/Automation-questions/How-would-one-create-multiple-tables-with-unique-JQL-search-when/qaq-p/2687506>

<https://community.atlassian.com/t5/Automation-questions/How-can-I-isolate-specific-issue-types-to-a-table-from-a-single/qaq-p/2688979#M10348>

Hope it helps.


author: Melissa C
body: [@Kalyan Sattaluri](/t5/user/viewprofilepage/user-id/5312306)

THANK YOU!!! THANK YOU!!!!

This has been a life saver! I got my report with the two tables! Thank you!

I've also created a couple of other reports!

I'm stuck on one syntax, do you have any suggestions or links that could be help with coming up with the correct syntax

I'm wanted to the list to show me all Tasks, that have been closed(resolved) in the last week. I'm not able to figure out the last part in the last week. Any suggestions?

{{#if(and(equals(issueType.name, "Task"),equals(status.name, "Closed"), and(resolved \<= startOfWeek(-1))))}}


author: Kalyan Sattaluri
body: Hello [@Melissa C](/t5/user/viewprofilepage/user-id/474554)

To add additional clauses to your checks, you need to include another if statement, because by default, an if statement will only take 2 paraments to check for OR /AND functions.

Please look at the bolded part below, make changes as per your issue set up and adjust the days check accordingly.

<br />

\<table border="1"\>  
\<tr\>  
\<th style="width:100px"\>Key\</th\>  
\<th style="width:150px"\>Issue Type\</th\>  
\<th style="width:150px"\>Assignee\</th\>  
\<th style="width:150px"\>Reporter\</th\>  
\<th style="width:1000px"\>Summary\</th\>  
\</tr\>

**{{#issues}}**

**{{#if(and(equals(issueType.name, "Task"), equals(status.name, "Closed")))}} {{#if(now.diff(resolved).days.gt(-7))}}**   
\<tr\>  
\<td\>\<a href="{{url}}"\>{{Key}}\</a\>\</td\>  
\<td\>{{fields.issuetype.name}}\</td\>  
\<td\>{{assignee.displayName}}\</td\>  
\<td\>{{reporter.displayName}}\</td\>  
\<td\>{{resolved}}\</td\>  
\</tr\>  
{{/}}  
{{/}}  
{{/}}\</table\>

Hope it helps!


author: Mauricio Heberle
body: Try using:  

\<{{fields.customfield_xxxxx}}\>

comments: author: Melissa C
body: [@Mauricio Heberle](/t5/user/viewprofilepage/user-id/4973359) Thanks!

But that doesn't work! So close!!


Tags: issues

lookup

smart-value