Variable set to random value

Dean Ayres January 23, 2025

Hi,

I'm fairly new to Jira automations

I'm trying to set a variable based on the output of random() which i'll use later in a webhook.

The problem is that it only seems to evaluate the presence of the value rather than the value itself and always returns SEC (in the example below). using https://support.atlassian.com/cloud-automation/docs/jira-smart-values-conditional-logic/  as a reference:

{{if(RANDOM().gt(0.5), "PRI", "SEC")}}

Am I mis-understanding how the if function works in jira?

Thanks

1 answer

0 votes
Tuncay Senturk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 23, 2025

Hello @Dean Ayres 

Your code seems OK, but let's try a different approach.

Create a variable and set it with the random value and then use conditional logic on the variable.

- Add an action Set Variable and set the variable  with {{RANDOM()}}

- add another action and use conditional logic as below

{{#if(randomValue.gt(0.5))}}
PRI
{{else}}
SEC
{{/}}

I hope it helps

Dean Ayres January 23, 2025

I've played about with this for a bit and fixed the value of randomValue to 0.8, but the output seems to be empty:

Screenshot 2025-01-23 145627.png

--

Screenshot 2025-01-23 145805.png

 

The audit log suggests the operation was a success 

Dean Ayres January 23, 2025

Even worse, if i commit  {{RANDOM()}} to the smartvalue it also returns empty:Screenshot 2025-01-23 150108.png

Dean Ayres January 23, 2025

{{#=}}RANDOM(){{/}}

Suggest an answer

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

Atlassian Community Events