How do I automate using a Jira lookup list with conditional logic for the issue's component?

Lindsay Sullivan March 11, 2024

Background:

I have used a successful automation for over a year that looks up the tickets completed in the last week, and emails:

  • a list of the completed tickets, matching the condition of specific epic link

This is the successful automation's content:

  1. LOOKUP ISSUES operation - JQL is:
    1. project = "PROJECT NAME" AND status changed TO "Done" AFTER -7d
  2. EMAIL - content:
    1. <strong>Back Office Functionality</strong>

      {{#lookupIssues}}
      {{#if(equals(epic Link.key, "SMGPORTAL-2226"))}}
      <li><a href=https://cylogy.jira.com/servicedesk/customer/portal/8/{{key}}>{{key}}</a> | {{summary}} ({{website}})</li>
      {{/}}
      {{/}}

    2. This repeats for 5 different epic links

The email looks like:

Title

(repeated for 5 different epic links)

 


My problem:

I need to organize this list based on the component now, not the epic link. I can not find a smart value for the component that works. I have tried all the below. I have read all the documentation and searched other community posts. All my tests return no results.

My request:

  • Please advise what should replace epic Link.key for component name?
    • Or is there a different syntax to achieve my outcome?

I am looking for the same email outcome as above, but it will be based on the component instead of epic link.

 

What I've tried, with no success:

{{#lookupIssues}}
{{#if(contains(issue.components.name, "Back Office Functionality"))}}

 

{{#lookupIssues}}
{{#if(contains(issue.component.name, "Back Office Functionality"))}}

 

{{#lookupIssues}}
{{#if(contains(components.name, "Back Office Functionality"))}}

 

{{#lookupIssues}}
{{#if(contains(components, "Back Office Functionality"))}}

 

{{#lookupIssues}}
{{#if(contains(issue.component, "Back Office Functionality"))}}

 

{{#lookupIssues}}
{{#if(contains(issue.components, "Back Office Functionality"))}}

 

{{#lookupIssues}}
{{#if(contains(ComponentName, "Back Office Functionality"))}}

 

2 answers

1 accepted

2 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.
March 11, 2024

Hi @Lindsay Sullivan 

In my experience...Components are one of those smart values which behave like a list and an array in rules, depending upon the context.  To do what you ask, please try this:

{{#lookupIssues}}{{#if(components.name.match("(blue comp)").size.gt(0))}}{{key}}; {{/}}{{/}}

How this works:

  • Iterate over the looked up issues
  • Filtering on the components field's name attribute with the match() function to iterate over the name values, filtering for one value.  In my example, I am looking for "blue comp".
  • The match result will be a list, and so we use the size of the list, and only proceed if the number is greater than 0.  (It really can only be null or 1, but this syntax handles the null better.)
  • When found, return the issue key

Please adjust for your component values and whatever you need returned from the lookup.

Kind regards,
Bill

Lindsay Sullivan March 12, 2024

Hi @Bill Sheboy ,

I should have posted this months ago.... that totally worked.

How did you learn that? I haven't seen that syntax in the smart value and lookup documentation.

Final outcome:

<strong>Back Office Functionality</strong>

{{#lookupIssues}}{{#if(components.name.match("(Back Office Functionality)").size.gt(0))}}<li><a href=https://cylogy.jira.com/servicedesk/customer/portal/8/{{key}}>{{key}}</a> | {{summary}} ({{website}})</li>{{/}}{{/}}

 

Looks like:

Title

(repeated for 5 different components)

 

Thank you!

Lindsay

Like Bill Sheboy likes 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.
March 12, 2024

Awesome; I am glad to learn that helped!

 

I have learned many things about automation rules by experimentation and reading posts in the community.  I recommend watching the automation product area for new articles and discussions:

https://community.atlassian.com/t5/Atlassian-Automation/ct-p/automation

That is where details of smart value, list filtering was first described: https://community.atlassian.com/t5/Automation-articles/Filtering-smart-value-lists/ba-p/1827588

 

Also in the documentation, some of the really helpful stuff is only shown in the examples, and not in the top-level links:

Screenshot 2024-03-12 130807.png

Screenshot 2024-03-12 130739.png

Lindsay Sullivan March 13, 2024

Thank you for the references. 

 

Can you advise how I can adjust the syntax so it lists tickets without a component (component = empty)?

 

Thanks,

Lindsay

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.
March 13, 2024

There are several ways to do that check, and two of them are:

{{#lookupIssues}}{{#if(components.name.size.eq(0))}}{{key}}; {{/}}{{/}}

or

{{#lookupIssues}}{{#if(components.name.isEmpty())}}{{key}}; {{/}}{{/}}

 

Lindsay Sullivan March 14, 2024

I used the second one, thank you!

Like Bill Sheboy likes this
0 votes
Kalyan Sattaluri
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.
March 11, 2024

Hi @Lindsay Sullivan 

Based on how fixVersion works, I would have expected {{lookupIssues.components.name}} to work, at least to print them out.. But its not. Guess its one of them fields which isnt exposed in lookupIssues data.

Hopefully others can share if they are able to make it work.

*if* components is not exposed through lookupIssues but you still want to do it, you may have to make a REST call to search for the issues and implement this logic that way.

 

 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events