Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Compare field values from current issue and issues from lookupIssues function with if-condition?

Marvin Brand
Contributor
September 9, 2025

Hey community I need your help here, 

I want to make use of the {{#lookupIssues}} function and use if-condition for further filtering the fetched issues.

Use case:

I want to two lookupIssues lists in a comment or description field.

The first Issue list:

Every fetched issue should be checked whether its "customfield_10110" has the same value as the "customfield_10110" from the current issue, where the automation is triggered from. If it returns TRUE, the issue key should be listed in a bullet point list.

The second issue list should contain all the other issues, where the condition is not met.

FYI: In customfield_10110 we store supplier names. So in other words I want to get a list of other issues, which have the same supplier in the custom field like in the trigger (current) issue.

It seems like I cannot compare a value from the current (trigger) issue with a value of the looked-up issues. The manual triggered automation won't create a comment or post a new description field text.

I tried the following things:

Test 1 – referencing the 2nd compare value (from trigger issue) with a smart value in  {{brackets}}

{{#lookupIssues}}
{{#if(equals(customfield_10110,{{issue.customfield_10110}}))}}
* {{key}}
{{/}}

Test 2 – referencing the 2nd compare value (from trigger issue)  with a smart value in "{{brackets and quotes}}" to make it a string

{{#lookupIssues}}
{{#if(equals(customfield_10110,"{{issue.customfield_10110}}"))}}
* {{key}}
{{/}}

 

Test 3 – storing the supplier name (customfield_10110) as a variable "currentsupplier" and trying to reuse the variable in the if-condition

{{#lookupIssues}}
{{#if(equals(customfield_10110,{{currentsupplier}}))}}
* {{key}}
{{/}} 

 

Any ideas folks? 

Please guys, have a solution for me 

Thanks in advance!

Marvin

 

2 answers

1 accepted

3 votes
Answer accepted
Bill Sheboy
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.
September 9, 2025

Hi @Marvin Brand 

I just saw your new question, and gave an answer to your other post:

Long-format iterators have a known limitation where they cannot "see" data from outside their scope.  And so once inside those {{#lookupIssues}} ... {{/}} iterators, they cannot access other issues, variables, etc.

There are two possible workarounds for your scenario:

  1. Add your criteria to the JQL for the lookup action, and store the resulting keys in a variable (or lookup table) for later use.  Then repeat those steps for each lookup needed.
  2. To use a single lookup work item action, use the dynamic searching methods described throughout the list-filtering thread, or in this article I wrote on the method.

 

Kind regards,
Bill

Marvin Brand
Contributor
September 10, 2025

Hey @Bill Sheboy ,

Thanks for help.

Since option 2 (working with one lookupIssue function) looks like a little too advanced for me, I'll try working with a Lookup Table first. It also would be OK for me working with two lookupIssue functions.

Nevertheless I'm also struggling with option 1. Here's my automation setup so far:

The lookupIssue function in this case returns 4 issues.

Bildschirmfoto 2025-09-10 um 08.56.35.png

Results in the comment:

Bildschirmfoto 2025-09-10 um 08.56.47.png

My goal is to have kind of like a list format with bullet points (or even a table, but this is for later). Kind of like this:

  • Printer 1 | Summary 1
  • Printer 2 | Summary 2
  • Printer 3 | Summary 3
  • Printer 4 | Summary 4

Any ideas how to get the lookup table formatted like this?

Bill Sheboy
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.
September 10, 2025

Hi @Marvin Brand 

For that first method, you may store the entire {{lookupIssues}} result in the table, and then use it directly.  This is a good technique to have multiple lookup results as it preserves the object structure.

For example:

  • action: lookup work items, with your first JQL
  • action: create lookup table
    • variable name: varFirstTable
    • row
      • key: First
      • value: {{lookupIssues}}
  • action: lookup work items, with your second JQL
  • action: create lookup table
    • variable name: varSecondTable
    • row
      • key: Second
      • value: {{lookupIssues}}
  • then, to use these results...
My First Results:
{{#varFirstTable.get("First")}}
* {{key}} -- {{summary}}
{{/}}


My Second Results:
{{#varSecondTable.get("Second")}}
* {{key}} -- {{summary}}
{{/}}

 

Marvin Brand
Contributor
September 10, 2025

@Bill Sheboy you are my hero here! Works like charm!

One last question: is it possible to limit the results from the look up table or the lookupIssues function?

In my sql query I ordered the search results by "resolved DESC" and only want to show for example 20 entries. "The last 20 related issues" according to my query, so to say…

Thanks in advance! <3

Bill Sheboy
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.
September 10, 2025

Filtering for a specific count of items cannot be done in one step because:

  • JQL is not a SQL and does not have support for operators such as TOP 20, and
  • the {{index}} smart value for lists cannot be filtered upon directly.

 

A simple workaround to get fewer, but perhaps not exactly 20 items, is to add more criteria to your JQL.  For example:

your JQL expression
AND resolved >= -10d
ORDER BY resolved DESC

And repeat the lookup without the additional JQL to get the full count, as needed.

 

A more complicated workaround requires created variables and dynamic regular expressions.  The basic outline is:

  1. convert the lookup result into a delimited text string with the index, key, etc. fields, storing the result in a created variable, such as: 0:ABC-123, 1:ABC-789, 2:ABC-456...
  2. create a dynamic regular expression to grab just the first N items, storing that in another variable, such as this for the first five records: ^((0|1|2|3|4):.*)$
  3. split the first variable back into a list, filter with match() and the regular expression, and then parse out the desired data with text functions

If you want to try this, please see this very long article I wrote using the techniques involved for a different use case.

0 votes
Trudy Claspill
Community Champion
September 9, 2025

Hello @Marvin Brand 

What is the field type for customfield_10110?

Looking at the example for using If and equals it seems like this should work:

{{#if(equals(customfield_10110,triggerIssue.customfield_10110))}}

{{#lookupIssues}}
{{#if(equals(customfield_10110,triggerIssue.customfield_10110))}}
* {{key}}
{{/}}
{{/}}

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

I believe you need {{/}} twice; once for the {{#if and once for the {{#lookupIssues

Trudy Claspill
Community Champion
September 9, 2025

I didn't see @Bill Sheboy 's response before posting my own.

Bill knows way more about the complexities of Automation than I do, so his answer is more likely to be correct than my untested theory.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events