Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How can I filter through lookupIssues with if statement

Vitali Fedarau September 14, 2022

I need to create a report with Jira automation, that will combine tasks by epics, like that:

Epic 1:

Task 1

Task 2

Epic 2:

Task 3

Task 4

I have gon through A LOT of articles and made A LOT of testing, but the best possible result I see the usage of filtering through lookupIssues. I have used this article as basis for that: https://community.atlassian.com/t5/Automation-articles/Filtering-smart-value-lists/ba-p/1827588

In my head, it should work in some way like this:

{{#lookupIssues}}
{{ #if({{equals(issue.epic.key,"EPIC-1"))}}}}

Epic 1 sumary
<{{url}}|{{key}} {{summary}}>
{{ /}}
{{/}}

 

{{#lookupIssues}}
{{ #if({{equals(issue.epic.key,"EPIC-2"))}}}}
Epic 2 summary
<{{url}}|{{key}} {{summary}}>
{{ /}}
{{/}}

So kinda filtering through epic key should allow to show only those tasks who are part of EPIC-1 or EPIC2. Unfortunately, that doesn't work at all.

Does anyone know what is the good way of doing this?

2 answers

Suggest an answer

Log in or Sign up to answer
1 vote
Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 14, 2022

Hi @Vitali Fedarau ,

How does your rule look like? What does your filter/query in the lookupIssues actions look like?

Could you please provide a screenshot of your automation rule/how far you´ve come so far?

Best
Stefan

Vitali Fedarau September 18, 2022

Hey, @Stefan Salzl Sure, but I think as we are going through simple lookup, it will be just a simple lookup...Screenshot 2022-09-18 at 19.44.11.png

Soooooo that basically it... As you can see I just have 1 lookup, that takes all done tickets in a closing sprint and mark it as lookup and then I iterate over lookup and grab all the tickets done. 

So, going back to my question, my understanding of this article should allow me to somehow filter this big lookup of tasks, so I can do some filter breakup in the report like

Stories:

Story 1 Story 2

Tasks

Task 1 Task 2

etc...

I basically can achieve the same with multiple lookups, but for multiple lookups I have issues with "if" as well (Does it seem like IF functionality in Jira Automation not working at all?) (my issue with "if": https://community.atlassian.com/t5/Adaptavist-questions/How-to-use-custom-Variables-in-conditional-logic/qaq-p/2135302#U2138139)

BTW, as you can see, I have 2 issue open at the same time for atlassian community, the reason for that - I am trying to achieve that with 2 different ways, either with multiple lookups or with sorting the 1 lookup. None of 2 approaches work so far, so I am trying to make work at least one.

Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 19, 2022

Hi @Vitali Fedarau ,

let´s take one step back. Could you please explain the problem you are trying to solve from a functional/use case perspective?

So I kinda understand what you are technically doing. I´m not quite sure if I can follow what exactly it should solve. 

With knowing this it would be easier to follow the steps and try to reproduce and find a solution.

 

Best
Stefan

Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 19, 2022

I tried to test as far as I understood your requirement correctly.

so here is my action in the automation rule:

image.png

which delivered following result in the email:

image.png

 

Of course this needs to be configured according to your JQL.

 

Hope this was helpful.

Best
Stefan

Vitali Fedarau September 20, 2022

Hey, @Stefan Salzl 

First of all thanks a lot for your help!

It works indeed!

Unfortunately, I finally found an issue that I am experiencing and why,

My initial goal was to sort tickets per Epic Link, so I have started to do that step by step,

Now I can see why yours with type working and mine with 

{{#lookupIssues}}
{{#if(equals(issue.epic.key, "TESA-4"))}}
<{{url}}|{{key}} {{summary}}>
{{/}}
{{/}}

Doesnt work, all because lookupIssues doesn't have epics as part of lookupIssues object

Screenshot 2022-09-20 at 20.28.39.pngSo that means I can finally make a report based on Issue types, but can't make a report based on Epic Links...

Which means that I should come back to multiple lookups solution,

Anyway thank you very much, you helped a lot to finally understand the issue!

BTW if you have any idea how to sort ticket per Epic Links I would appreciate that :D

Best Regards,

Vitali Fedarau

Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 20, 2022

I just gave it a shot:

epic from lookup: {{lookupIssues.epic Link}}

delivered the epic keys:

image.png 

Vitali Fedarau September 20, 2022

Hmmmmmm, interesting, @Stefan Salzl , so you kinda referring to lookupIssues object, right?

So in my case for filtering it should look like something this?

{{#lookupIssues}}
   {{#if(equals(lookupIssues.epic Key, "TESA-4"))}}
      <{{url}}|{{key}} {{summary}}>
   {{/}}
{{/}}

If yes, this case this didnt work for me :(

Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 21, 2022

Hi @Vitali Fedarau 

please try the following:

{{#lookupIssues}}
   {{#if(equals(lookupIssues.epic Link.key, "TESA-4"))}}
      <{{url}}|{{key}} {{summary}}>
   {{/}}
{{/}}

 

Best
Stefan

Vitali Fedarau September 21, 2022

Hey, @Stefan Salzl 

Thanks a lot as usual,

But unfortunately it didnt work :(

{{#lookupIssues}}
{{#if(equals(lookupIssues.epic Link.summary, "Test Epic 1"))}}
<{{url}}|{{key}} {{summary}}>
{{/}}
{{/}}

Didn work either :(

Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 21, 2022

Could you please add my previous suggestion to a "Log action" and send me a screenshot of the audit log of the activation?

{{#lookupIssues}}
   {{#if(equals(lookupIssues.epic Link.key, "TESA-4"))}}
      <{{url}}|{{key}} {{summary}}>
   {{/}}
{{/}}

 

Best
Stefan

Like Mauricio Heberle likes this
Vitali Fedarau September 21, 2022

Sure! @Stefan Salzl  

Thats what i have when I add 

{{#lookupIssues}}
   {{#if(equals(lookupIssues.epic Link.key, "TESA-4"))}}
      <{{url}}|{{key}} {{summary}}>
   {{/}}
{{/}}

Fully to Log Audit

 Screenshot 2022-09-21 at 17.23.24.png

 

And that is what interesting here, that this actually shows proper Log result

Screenshot 2022-09-21 at 17.25.21.png

But now I have 0 idea how to properly specify the if condition to make it actually work, looks like {{lookupIssues.epic Link.key}} giving all epic keys that issues in 1 object, and not sorting it issue by issue

Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 21, 2022

ooouh sorry.....my bad :/

I did a copy-paste-error. As we are already iterating over lookupIssues we do not neet this information in the if-condition. Here is the correct one:

 

{{#lookupIssues}}
   {{#if(equals(epic Link.key, "TESA-4"))}}
      <{{url}}|{{key}} {{summary}}>
   {{/}}
{{/}}

 

iterating over a list is (as far as I know) not meant to react that dynamically or sorting a list. It is going through the list that resulting from the lookup and handle some conditions within. 

One thing that might help would be to sort your jql in the lookup action (order by "Epic Link" DESC).

Best
Stefan 

Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 21, 2022

Would the epic keys for the if condition need to be generated "dynamically" or do you have a fix list of epics and can the be hardcoded?

Vitali Fedarau September 21, 2022

HELL YEAH IT WORKED!

Thanks a lot, @Stefan Salzl you made it work finally!

For the dynamic -  if we could do that "dynamically" that would be great, but right now I am looking into the hardcoded solution, as it seems like more simple, I didnt invent in my head the solution with dynamic epics,

The only thing I have so far that doesn't seem cool is that it repeats the Epic Name each time as it iterates over and over

Screenshot 2022-09-21 at 20.41.32.png

The Code I have used:

{{#lookupIssues}}
   {{#if(equals(epic Link.key, "TESA-4"))}}
      <strong>Setup Store</strong>
      <{{url}}|{{key}} {{summary}}>
   {{/}}
{{/}}

Looks like at this moment of time I have to hardcode the name of the epic above like this:

<strong>Setup Store</strong>

{{#lookupIssues}}
   {{#if(equals(epic Link.key, "TESA-4"))}
      <{{url}}|{{key}} {{summary}}>
   {{/}}
{{/}}

@Stefan Salzl If you have any idea how to make it under 1 cut, I will really appreciate it,

But even still, I own you a lot of beers for your help! :D

Best Regards,

Vitali

Like # people like this
Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 21, 2022

Hi @Vitali Fedarau 

you are welcome my friend. hahaha.....and would enjoy to raise our glasses on this effort with you ;) Really great to know you got that working 💪

 

AND: It was my pleasure. You owe me nothing haha.....that´s what the community is meant for. We love to seek for solutions and even learn new things :)

 

I really tried hard but I couldn´t find any easier way to do it in 1 cut. I also considered:

- advanced branching (for each) --> then an email would have been sent for each epic =S
- JQL branching (couldn´t find a solution)
- branch for all issues of sprint (no idea either)

But maybe those ideas could be inspiration for you =)

 

If my answer did help please consider to hit the Accept button ;)

 

Best
Stefan

gsharma March 20, 2023

@vitali @Stefan Salzl Thanks a lot for this thread. It was very helpful to understand the templating. I'm trying to do the same thing (group issues by Epic) and would like to get the Epics dynamically.

I got the dynamic Epics working, but have two issues:

  1. I can't get the lookupIssues loop to work inside the epics loop.
  2. How do I check for the Epic inside the lookupIssues?

 

# epics = {{lookupIssues.epic.summary.distinct}}

{{#epics.split(",")}}
<strong>{{.}}</strong> # Prints fine
{{#lookupIssues}}
<a href="{{url}}">{{key}}</a> - {{summary}}</li> # Doesn't print at all
{{/}}
{{/}}

Assuming lookupIssues block prints the output, I still need to reference "{{.}}" from the Epics block to the lookupIssues. Any insights will be helpful.

0 votes
Vitali Fedarau September 21, 2022

Null

TAGS
AUG Leaders

Atlassian Community Events