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

How to get item's index in list by its name?

axone April 13, 2022

Hello community!

The problem I'm trying to solve is to figure out is a version in a project is archived.
The closest thing I came up with is

{{project.versions.get(6).archived}}

But I would like to access the property by its name, not by its index.

The only thing I can think of is to iterate throughout the versions and to find my version by myself. But there must be an easier way.

1 answer

1 accepted

0 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 13, 2022

Hi @axone -- Welcome to the Atlassian Community!

Without seeing your complete rule, I believe the answer is "maybe".

If you are trying to find a specifically named issue (i.e. literal value) in the list, you could try filtering the smart value list on the name, and then access the archived attribute: https://community.atlassian.com/t5/Automation-articles/Filtering-smart-value-lists/ba-p/1827588

If instead you are trying to use a dynamic value for filtering, such as from an issue's field or created variable, filtering does not work.  Instead you would need to walk the list in an advanced branch and use conditional logic to test archived.

Kind regards,
Bill

axone April 15, 2022

Hi Bill.

The first method you suggested seems to be working for me. Thinks! That's the one I was hoping to avoid, though :D

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 15, 2022

Now that I think about this...another way that might work is to expand your versions into a list with your own delimiters, iterate the list, use a regular expression with match() to find the desired name (which can use smart values as params), and then check the archived attribute.  Please note, I have not tried this.

axone April 15, 2022

Nah, this is also looks quite complicated )

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events