Random Number

<< Click to Display Table of Contents >>

Navigation:  Bizagi Studio > Process wizard > Business Rules > Business rules examples > Perform Math operations >

Random Number

Overview

This section describes Bizagi random number functions. These functions are as follows:

Rand(from,to)

Rand()

 

Rand (from,to)

This function returns an integer random number between two numbers.

 

CHelper.Math.Rand(ValueFrom,ValueTo)

 

The parameters of this function can be defined as Xpaths, variables or numbers.

 

Considerations

Input parameters must be integers.

The supported attribute type to use as input XPath parameter (or Xpaths stored in variables) is integer.

The function returns an error if the ValueFrom is greater than the ValueTo parameter.

Use the IsNaN function to validate the parameters used are numbers.

 

Example

A company uses Bizagi to raffle different prizes among its clients. Each customer is given a number between 0 and 100. Bizagi must generate a random number between the available numbers to obtain a winner.

 

To implement this logic you can use the Rand function:

 

Math10

 

//Generate the winner number

<RaffleProcees.WinnerNumber> = CHelper.Math.Rand(0,100)

 

Rand()

This function returns a decimal between 0.0 to 1.0, and it has NO parameters.

 

CHelper.Math.Rand()

 

Example

Suppose you need to generate a random number between 10 and 20 with two decimal places.

You have to use two functions: one to generate a random number between 10 and 20 and one to generate the decimal places. Then you can add both results.

 

 

Math25

 

<Request.RandomNumber> = (CHelper.Math.Rand(10,20))+(CHelper.Math.Rand())