Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,369,757
Community Members
 
Community Events
168
Community Groups

How can I filter through lookupIssues with if statement

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

0 votes
Stefan Salzl Community Leader Sep 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

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 Sep 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 Sep 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

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 Sep 20, 2022

I just gave it a shot:

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

delivered the epic keys:

image.png 

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 Sep 21, 2022

Hi @Vitali Fedarau 

please try the following:

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

 

Best
Stefan

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 Sep 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

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 Sep 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 Sep 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?

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 Stefan Salzl likes this
Stefan Salzl Community Leader Sep 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

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events