Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Automation Smart Values: Comparing a custom variable inside a list "loop"

Ludwig Einicke
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 11, 2025

Dear Community,

I am working with automations and currently stumped by a seemingly simple problem that I can find no working solution for. I am building an automation that looks up objects and returns the "fullest" object(s) judging by attributes counted. I will first provide the steps of what I am doing followed by where I run into a problem and what I have already tried:

 

0) Asset Objects ready to be looked up:

Object type: MyObjects

> Objects of this type can have a varying number of entries contained in their attributes. The main assumption is: "The more attribute entries an object contains, the more relevant it becomes as a query result".

MyObject Attributes:

- Key (must be filled and limited to 1 entry, must be unique)

- Name (must be filled and limited to 1 entry, must be unique)

- A1 (can be empty, can have multiple entries)

- A2 (can be empty, can have max. 1 entry)

- [...]

 

1) Automation step-by-step:

1.1) Lookup-Objects

Query: Some Query that returns multiple objects from type MyObjects.

Output: {{LookupObjects}} with SmartObjects represented by tag. For example "KEY-1, KEY-4, [...], KEY-12"

> List of Asset-Objects matching some search criteria gets filled into {{LookupObjects}}

1.2) Create Variable {{CountFilledAttributes}}

Smart Value: {{#lookupObjects.attributes}}{{size.asNumber}},{{/}}

> count of "how mighty" each object is (how many filled attributes it contains). Output e.g. "12,13,12,10,12,[...],12,"

1.3) Create Variable {{AttributeCountMax}}

Smart Value: {{CountFilledAttributes.split(",").max}}

> Returns the maximum Number from the previous list. Output e.g. "13"

1.4) Create Variable {{ObjectsWithMaxCount}}

Smart Value: {{#lookupObjects}}{{#if(equals(attributes.size.asNumber, $AttributeCountMax.asNumber))}}{{.}}, {{/}}~{{/}}

> Should make a list containing only objects that have the priviously found maximum number of attributes. "~" is contained for Debug porpuses, will be dropped in final iteration

1.5) Audit-Log

Objects initially found: {{LookupObjects}} || Attribute Counts: {{CountFilledAttributes}} || Max Count: {{AttributeCountMax}} || Objects with Max Count: {{ObjectsWithMaxCount}}

 

2) My problem:

For this example: {{ObjectsWithMaxCount}} does not work properly and returns only "~~~~[...]~"

In general: How do i get the smart object to use my smar variable {{AttributeCountMax}} while iterating over the listed items from {{LookupObjects}}? I know that there are threads close to this subject but I can't find any tackling this specific subject.

I am aware and confident that I could restructure this to run and work using custom branching and I will do so if actually necessary - even if it feels a bit inelegant (I strongly suspect it will result in quite a bit of additional runtime). I still pose this question as I would love to deepen my understanding about automation function behaviour here, please bear with me (and let me extend a big thanks at everyone helping me here).

 

3) What i have tried

3.1) {{#lookupObjects}}{{#if(equals(attributes.size.asNumber, 13))}}{{.}}, {{/}}~{{/}}

> returns the expected result. e.g. "~KEY-4,~~[...]~

3.2) {{#lookupObjects}}{{#if(equals(attributes.size.asNumber, AttributeCountMax))}}{{.}}, {{/}}~{{/}}

> returns incorrect result. e.g. "~~~[...]~". Kind of expected because "AttributeCountMax" obviously does not exist as an Attribute on the asset objects so NULL would be returned, making the equals logic false on every comparison. (I checked if it would return all items if I would change attributes.size.asNumber into something that returns NULL and sure enough: All items from the list DID get returned.)

3.3) {{#lookupObjects}}{{#if(equals(attributes.size.asNumber, {{AttributeCountMax}}))}}{{.}}, {{/}}~{{/}}

> (expectedly) doesn't render. Automation hates nested curvy brackets

3.4) {{#lookupObjects}}{{#if(equals(attributes.size.asNumber, ${{AttributeCountMax}}))}}{{.}}, {{/}}~{{/}}

> doesn't render, $ doesn't seem make nested curvy brackets more palatable to our poor little automation.

3.5) {{#lookupObjects}}{{#if(equals(attributes.size.asNumber, (AttributeCountMax)))}}{{.}}, {{/}}~{{/}}

> doesn't render, automation also seems to hate random brackets

3.6) {{#lookupObjects}}{{#if(equals(attributes.size.asNumber, $(AttributeCountMax.asNumber)))}}{{.}}, {{/}}~{{/}}

> returns incorrect result. e.g. "~~~[...]~"

3.6) {{#lookupObjects}}{{#if(equals(attributes.size.asNumber, $(AttributeCountMax)))}}{{.}}, {{/}}~{{/}}

> returns incorrect result. e.g. "~~~[...]~"

3.7) {{#lookupObjects}}{{#if(equals(attributes.size.asNumber, $"AttributeCountMax"))}}{{.}}, {{/}}~{{/}}

> returns incorrect result. e.g. "~~~[...]~". At this point i am running out of ideas and I am gennerally unsure if the $ even does anything.

 

4) pleasehelp.jpg

I feel like i am missing just one syntax detail and I will be greatly thankful for any suggention and educational content on this matter.

 

Kind regards,

Ludwig

 

EDIT: fixed some typos

1 answer

0 votes
Benjamin Črnjak
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.
September 11, 2025

Hi @Ludwig Einicke , welcome to the community! 😊

We are happy to have you here. 😉

 

I've recreated your automation rule and tried with multiple different approaches. It seems that Jira automation won't recognize smart value inside nested functions or more likely, inside lookup object list with nested functions inside IF.
Because everything works before that, all variables are correct and available, but it doesn't work except with a branch.

Here is a branch I made and it returns correct results:

image.png

Create an advance branch against lookupobjects smart variable.
Then add IF as displayed on image above.
Print object if true.

 

Here are results:

image.png

 

I know you said you would like to avoid branch because of execution time, but unfortunately, I wasn't able to find better solution.

 

Hope this helps.

Regards,

Benjamin

Ludwig Einicke
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 12, 2025

Hello and thank you for the warm welcome Benjamin,

it definitely comes as a surprise to me that there is no way to tell a function "hey, you have to look into the defined variables to find this". This was before I dug around a little and found out that it is all a matter of perspective: From what I have found we can consider ourselves lucky that smart values work for at least the usual cases without nested functions during list-per-object-operations. The functionality seems to have been added as recently as 2022/2023(!). Maybe there will be some "escape operator" in the future.

Back the to main topic: It seems I have to use what i wanted to conciously avoid. Advanced branching sets up a new challenge - I need to find a way to transition this sulution from writing into an audit log to returning a list that I can use to further search and sort the objects.

I am imagining something like creating a variable before the branching that gets read into a brach-only variable and rewritten with the added results during the branching. This could run into some trouble: Are the branches even happening sequentially or will this run into some parallel execution problem? I will run some tests and report back live from the battlefield.

Kind regards,

Ludwig

Like Benjamin Črnjak likes this
Benjamin Črnjak
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.
September 12, 2025

@Ludwig Einicke currently I can't provide you with good solution, as I'm looking for solution myself for very similar problem as yours.
If I find out something new, I'll inform you here.

regards,

Benjamin

Suggest an answer

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

Atlassian Community Events