Automation Smart Value Help - 1 in 10 chance to trigger event
Asked by Daniel Shepperdson:

Hello Jira wizards, gurus, and everything in between!  

I'm trying to set up an automation rule on a random chance (1:10) event that looks something like this:  

**When** Issue transitions in workflow **\>** Create Smart Value 1-10 \> **If** Value = 1 **then** follow through **else** disregard.

Using the AI automation creator, it suggested the following formula:

**Then: Create variable**   
Variable name: randomNumber  
Smart value: {{math.randomInt(1,10)}}  

**If: Compare two values**   
First value: randomNumber (I have also tried {{randomNumber}} - Same results)  
Condition: equals  
Second value: 1

**Then...** However, the rule is not triggering as intended *(pronounced not triggering at all).*For the purposes of testing, I've set the values in math.randomInt to (1,2) for a 50% chance but have failed consistently.

When checking the audit log, it shows every entry as No actions performed / condition not met.

Any help / suggestions on how to make this or any other effective RNG rulesets work would be greatly appreciated.

Thank you!


Answers:
author: Trudy Claspill
body: Hello [@Daniel Shepperdson](/t5/user/viewprofilepage/user-id/5537257)

Welcome to the Atlassian community.

Where did you find the information that "math.randomint()" is a valid function for Jira Cloud Automation? Based on the [documentation](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-math-expressions/), there is no such function.

Given that there is no such function, the variable will never be set to 1.

Also, an excellent debugging tool is to use the [Log Action](https://support.atlassian.com/cloud-automation/docs/jira-automation-actions/#Log-action) to print the actual values of fields, smart values, and variables into the rule execution Audit Log so you can confirm they have the values you expect.

comments: author: Daniel Shepperdson
body: Hi Trudy,

It was provided by the 'Create With AI' service as a smart value. On another attempt it also suggested {{#=}}{{random(10)}}{{/}} which failed in the same fashion.


author: Trudy Claspill
body: I recommend that you always verify information generated by AI by referencing the documentation.

The documentation reference I provided references only the following with regard to the use of a RANDOM function.

![Screenshot 2024-07-10 at 4.03.20?PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/334813i347EF6D1B4B878CF/image-size/large?v=v2&px=999 "Screenshot 2024-07-10 at 4.03.20?PM.png")

I don't appear to have access to the "Create with AI" feature in the instances to which I have access, so I can't comment specifically on that.


author: Joseph Chung Yin
body: [@Daniel Shepperdson](/t5/user/viewprofilepage/user-id/5537257) -

Welcome to the community. It will be great if you can actually provide us with your current automation rule details, so we can review and assist you further.

For the Smart value setup, it seem you are simply setting a local variable and populate it with some value within the automation rule right?

Please advise.

Best, Joseph Chung Yin

comments: author: Daniel Shepperdson
body: Hi Joseph,

I've added screenshots of where the rule breaks \& the following action. The only prior step is "When issue is transitioned from \<Status A\> to \<Status B\>".

I've tried using {{randomNumber}} \& randomNumber as the variable name for both *Then: Create variable* and *If: Compare two values* with the same results.

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/334775iE087E9BE58DA3C0C/image-size/large?v=v2&px=999 "image.png")![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/334776iAD31AC06E7B4A801/image-size/large?v=v2&px=999 "image.png")


author: Joseph Chung Yin
body: [@Daniel Shepperdson](/t5/user/viewprofilepage/user-id/5537257) -

What is the {{randomNumber}} value have since you use "Create with AI" smart value syntax?

Best, Joseph


Tags: cloud

jira-service-management

jira-service-management-cloud