Random number selection via a rule

I’m not sure this is possible but here goes…

I have a rule that performs specific actions based on the value of a number item.

For example, if the number item state is 1 perform “A”, it the item state is 2 perform “B”, etc.

Usually the value of the number item can be determined by the user via a sitemap and mappings, however I’d like a rule to be able to make the selections. For this purpose it really doesn’t matter what selection the rule makes as long as it picks a number between 1 and 10. Is there a way to write a rule so it randomly selects a number between 1 and 10, then set a number item to the selected number?

I can achieve the same with a round-robin selection process if a rule is incapable of being a random number generator. However, i’m not sure how to do that either…

from demo.rules:

(Math::random * 10.0).intValue + 1

there is no special import for this in the demo.rules, it may be that you need to import

import java.lang.Math

though.

Everything in java.lang is imported by default so Math should be there without problem.