Forums

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

Automation selecting random insight asset

DavidBernardoSI1996
Contributor
August 7, 2023

Is there a way to create an automation that will create an issue and select one random insight asset to use in a field?

The asset needs to be random for compliance purposes.

1 answer

0 votes
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.
August 7, 2023

Hi @DavidBernardoSI1996 -- Welcome to the Atlassian Community!

Although I have never done that before...I wonder if you could use a combination of features of automation for Jira features to do this:

Kind regards,
Bill

DavidBernardoSI1996
Contributor
August 9, 2023

Hi thanks for the help, I've almost got the solution, there is just one last problem trying to access the index I want in a lookupObject.

First I'm creating a lookupObject, then I use the size of that lookupObject to get a random number between 1 and the total number of entries of the object, like so:

Captura de ecrã 2023-08-09 091738.png

After that I use another variable to do minus(1) since a want a value between 0 to the size of the object -1 (to access the index)

Captura de ecrã 2023-08-09 093255.png

Then when I'm creating the issue I'm trying to use the applicationIndexFinal to access the desired index in the lookupObjects:

Captura de ecrã 2023-08-09 093316.png

But this is the part that is not working, when I create the issue both the {{lookupObjects}}, the {{applicationIndex}} and {{applicationIndexFinal}} write values on the description, but not the {{lookupObjects.get(applicationIndexFinal)}}.

Example:

lookupObjects will write: Server1, Server2, Server3

applicationIndex will write: 2

applicationIndexFinal will write: 1

And then nothing more is written.

How can I use the applicationIndexFinal to access the value I want inside the lookupObjects?

Note: I'm writing in the description for testing purposes the value should then be inserted in the application field bellow.

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.
August 9, 2023

I believe that get() for Lookup Objects takes a numeric parameter, so try converting with asNumber.

And...I think you can do the index calculation in one variable if you subtract after the CEILING() function in the math expression.

DavidBernardoSI1996
Contributor
August 10, 2023

Thanks for your fast response, I've already tried this:

{{lookupObjects.get(applicationIndexFinal.asNumber)}}, but still nothing :/

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.
August 12, 2023

I wonder...unfortunately some smart value functions will not accept a created variable as a parameter.  Let's try this...

  • write that value to the audit log to confirm it is valid: {{applicationIndexFinal.asNumber}}
  • enter a hard-coded value in that get() to confirm it works as you expect
DavidBernardoSI1996
Contributor
August 16, 2023

Hello, this were the results of the test:

Captura de ecrã 2023-08-16 152134.pngCaptura de ecrã 2023-08-16 152150.png

DavidBernardoSI1996
Contributor
August 16, 2023

It seems it doesn't allow the use of the created variable... Is there any work around?

DavidBernardoSI1996
Contributor
August 16, 2023

Using this the log is empty:

Captura de ecrã 2023-08-16 154250.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.
August 16, 2023

Argh...this is one of those cases where a smart value function cannot take a variable (or smart value) as a parameter.  I'll ponder a bit for other work-arounds, and until then you may want to work with your site admin to ping the support team about this one:

https://support.atlassian.com/contact/#/

DavidBernardoSI1996
Contributor
September 7, 2023

Hello, haven't commented on this issue for a bit, but I've talked with support and there is a solution with the use of a lookup table with the lookupObjects and using the random function for the key. Thanks your help! :)

Like # people like 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.
September 7, 2023

I am glad to learn the support team offered an idea...and I believe the only reason that will work is Lookup Table's implementation of the get() function can take a parameter, unlike most of the other automation rule functions.

Sana
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!
January 31, 2024

@DavidBernardoSI1996 Can you explain how did you do it with lookup tables ?

Aleksandra Leesment
Contributor
October 3, 2024

+1 for Sana's comment

DavidBernardoSI1996
Contributor
October 4, 2024

Sorry for the long delay, but I've only seen the question about the solution today.

First get the list of assets from which you want to randomly select:

1.png

Then create a lookuptable, like so:

2.png

This is the code inside the Value field:

{{#=}}CEILING(RANDOM()*({{lookupObjects.size}} - 1)){{/}}

After that, to access the randomly selected asset use this:

3.png

Hope this helps!

Like # people like this

Suggest an answer

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

Atlassian Community Events