How to use Lookup Issues to retrieve a single custom field value in Automation for Jira Data Center
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
The Lookup Issues action was introduced to Automation for Jira Data Center in version 9.0.1, allowing users to query for issue properties and then use them in further actions. However, as stated in our documentation for the lookupIssues smart value, it only supports a limited range of properties and doesn't support retrieving arbitrary custom field values.
We currently have a suggestion to add this capability, but it hasn't been implemented yet: JIRAAUTOSERVER-877 - Lookup issue action - Add support for more fields
Environment
Automation for Jira Data Center 9.0.1 or later (bundled with Jira Data Center 9.11 or later)
Solution
In situations where we need to look up a single issue and retrieve a single custom field value, we can work around the limitations of the Lookup Issues action by using the Create Variable action, which was also introduced in Automation for Jira 9.0.1.
As a practical example, let's take the following scenario - we would like to implement a manual automation trigger for Epic issues that will search for all the issues under an Epic and do the following:
Set the Epic issue's Target start date to the earliest Target start date among the issues linked to the Epic.
Set the Epic issue's Target end date to the latest Target end date among the issues linked to the Epic.
We can do this by constructing an automation rule as follows:

The final Edit action of the rule can use the value:
1
2
3
4
5
6
{
"fields": {
"Target start": "{TargetStart)}",
"Target end": "{TargetEnd}}"
}
}
As can be seen above, the process is to first use Lookup issues to return a single issue key, then use that issue key in a For JQL branch and extract the custom field value from the branch using Create variable. We can then use the variable to set the original trigger issue's fields as desired.
Extended Solution
If we would like to automatically trigger the above process for a parent Epic whenever the Target start and Target end dates of a Bug or Story issue under it are updated, we can also do that, but the rule will be more complex because of the way in which Automation for Jira's related issue branching works:

The final Edit action of the rule can use the value:
1
2
3
4
5
6
{
"fields": {
"Target start": "{TargetStart)}",
"Target end": "{TargetEnd}}"
}
}
In Automation for Jira, the concept of a "related issue" excludes the triggering issue. This means that For JQL related branches will implicitly exclude the current issue's key from their JQL search results. As a result, if the earliest Target start date or latest Target end date belongs to the triggering issue then we need to detect that with an If/else conditional block and treat it as a special case, instead of relying solely on For JQL.
Was this helpful?