Getting a filtered subset of a lookupIssues smartvalue or multiple lookupIssues's

Jonathan Aspeling April 9, 2021

Good day all, 

 

What I'm doing:

Getting JQL results that get's stored as a lookupIssues smartvalue.

I reference the lookupIssues in a HTML Mail Template. 

I get a count of the items in the lookupIssues variable by going {{lookupIssues.size}} to use in the mail to indicate x amount of issues present.

What I would like to do

Filter the lookupIssues based on status of issues in the object. So that I can return two different counts based on the filter. 

Something like {{lookupIssues.size}}{{where status = 'Pending Customer Approval'}}

 

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.
April 9, 2021

Hi @Jonathan Aspeling 

How about this approach:

  1. Lookup Issues on one of the counts you need with JQL
  2. Save the count {{lookupIssues.size|0}} in a Created Variable
  3. Repeat steps 1-2 for as many counts as you need
  4. Create your email, referencing the created variables

If you need the specific details for each lookup in the email, now it gets fancier:

  • Once you have a lookup, iterate over the values to build the HTML for the email using text functions, and storing the result in a Created Variable
  • Repeat...
  • Build your email, using the pre-built HTML snippets

Best regards,

Bill

Jonathan Aspeling April 10, 2021

Excellent thanks @Bill Sheboy <3

I'll post back my final solution, How I interpreted and applied the first bit!

chrome_7bvcDRWleg.pngchrome_GgCaRzzOvH.png

Jonathan Aspeling April 10, 2021

Checking is the Highlighted bit read "Or Zero" kind of like a Coalesce. So if the size method returns null it makes it zero?

chrome_jrBcGccAJK.png

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.
April 12, 2021

Yes, that is correct.  The pipe symbol defines a default value when the operations leads to null.  Seems like a good defense for counting operations.

Jonathan Aspeling April 12, 2021

Cheers - thank for the input :D Really helped get me unstuck and let me create what I'm hoping will be the start of a beautiful thing for our Org and my Dept. 

I wrote the following in reflection after I managed to complete what I set out to do - if you're keen to have a quick look feel free. All ready noticed a few write up mistakes but not super serious and the just of the project is there ++ Credit to you haha
LinkedIn - Report - Jira Automated Dynamic Follow Up Emails 

Like # people like this
Brock Jolet January 17, 2022

Hey @Bill Sheboy I'm working on something very similar to this, but I'm curious if it's not possible to store the entire list of issues to a variable (without the ".size") and then filter them later on in the rule.

Example:
I do a {{lookupIssues}} and add that result to a custom variable called {{xAll}}.

If I ask for {{xAll}} in a Log Action, it returns the full list of issues from the lookup, but if I ask for {{xAll.size}} it returns null.

I'm making the assumption that custom variables store a string, but don't know how to convert that back to a list.

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.
January 18, 2022

Hi @Brock Jolet 

I recall reading another post about the Atlassian team working on preserving typing in created variables, rather than cast to string.

Until then, you probably need to either:

  1. save the Lookup Issues information in a created variable, and then use split() to pull back into a list before using size()...or
  2. if you need fewer details, prune down the results of lookup issues in to just the fields you need, define your own structure, and later split/parse accordingly.

In either case, this may take some experimentation as the lookup issues result is either null or a list of 1-to-many issues.  Try setting the created variable and then logging the results.  And, lookup now contains all fields so option #2 may work better for performance.

Kind regards,
Bill

Like Brock Jolet likes this
0 votes
John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 9, 2021

Hi Jonathan, 

I don't believe you are going to be able to get two different sets of values in the same email like that.

Suggest an answer

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

Atlassian Community Events