Automations: how to use a variable inside a smart value list.get()

Eric Rodewald September 10, 2020

I am trying to pull a random item out of an array from a json webhook request. I've got the following done:


  1. create variables rand, listSize, newIndex
  2. run the webhook request, delay for response
  3. (works) set rand to:
  4. (works) set listSize to:
  5. (works) set newIndex to:
    {{#=}}FLOOR({{listSize}} * {{rand}}){{/}}
  6. (works) verify this index is not a string by setting newIndex again to:
  7. (fails) obtain by the new index with:

Unfortunately, this doesn't work at all. I've tried variations like:



 When I just use a raw literal number, it works fine. e.g.,


Not really helpful if I'm building a random function, basically.


Am I missing some nuance about the syntax here? Thanks

5 answers

2 votes
Charlie Mullins February 16, 2022

Has this been resolved? Im having the same problems

1 vote
Aleksandra Leesment November 8, 2023


0 votes
Lauren Benson November 8, 2023

See the answer here where they first generate the index as a smartValue, then set that as an issueProperty, which is accessed within the .get( ) function.   

Aleksandra Leesment November 9, 2023

Thank you for suggestion! I will try it out

Like Lauren Benson likes this
0 votes
Gregory Riccardi September 24, 2023

Just spent a weekend trying to get something done with this. Such a stupid limitation!   

0 votes
Sam Harding
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 22, 2020

Hi Eric,

Thank you for your patience waiting on an answer for your problem. We have been looking into it, and trying to find a solution for your use case. Unfortunately, the current implementation of custom variables only allows for storing of values as strings. So 'newIndex' in your rule is always evaluated as a string, regardless of its original type. This is a limitation we are aware of, and is something we are working towards solving. 

Within that limitation, I do not believe there is a way for you to do what you are wanting. I have raised this internally with the team, and we will hopefully be able to provide the functionality you are wanting in the near future.


Eric Rodewald September 23, 2020

Thanks for responding. I started to realize that and abandoned this technique, but even if there was a "JSON.parse()"-esque function that could be used to parse and obtain a value, it could be used inline in a way that doesn't require persisting it as an object.

For what it's worth, I made a naive version of this where I store a number of strings in variables and then used a random function to traverse through several conditionals to select a value.

Looking forward to seeing what you guys come up with for a better long term solution.

Like Sam Harding likes this
Priska Aprilia May 17, 2022

Hi @Sam Harding 
Is there any update on this limitation?
I ran into the similar situation where I have two separate lists with the same length and there is a need to get the item of the second list based on the current index of the first list. Hence I need a function where I get pass a variable in the get() function.


Gordon Thomas August 13, 2022

Have you tried the following?

Deiser Service Team August 19, 2022

Hi. Gordon.

It does not work either. By any reason the 'get' function only can be used with fixed numbers. I have the same issue.

Actually, in no function with numeric parameters (charAt, left, etc.) you can use a variable, even with 'asNumer' sufix.

Smartvalues is a real pain for developers.


Like Pieter Wouter Hartog likes this
Gordon Thomas August 19, 2022

Smartvalues is a real pain for developers.

There are few statements truer than this. 

The inconsistency in the conditions under which different methods/expressions operate, combined with the limitations on using different data structures...

It feels like every single possible permutation of expressions has to be tested individually to determine if it will be interpreted correctly.

Like # people like this
Sebastian Krzyzanowski May 8, 2023

Just wasted a day of my life to get an list index to be stored inside a variable... only to find out, I can't set FixVersion with a certain version by accessing the list of versions with the help of my variable. 

I hate days like this 🙁


Failed to get value for issue.project.versions.get({{myindex: {{issue.project.versions.get({{myindex}})}}
Like Lauren Benson likes this

Suggest an answer

Log in or Sign up to answer