Create random number
Function: Create random number
This action generates a random number within a specified range and stores it in a new variable within your application's scope. This is useful for tasks requiring unique identifiers, random selections, or numerical simulations.
Input
- Maximum value (MAX): The highest possible number to generate. (Type: Number)
- Minimum value (MIN): The lowest possible number to generate. (Type: Number)
Output
- Variable name (NAME): The name of the variable to store in the variable scope. (Type: Number)
Execution Flow
Real-Life Examples
Here are some practical ways you can use the "Create random number" action in your applications:
Example 1: Generating a unique order ID
You need to assign a unique, random order ID to each new customer order.
- Inputs:
- Maximum value:
99999 - Minimum value:
10000 - Variable name:
OrderID
- Maximum value:
- Result: A new variable named
OrderIDis created in your application's scope, containing a random number between 10000 and 99999 (e.g.,54321). ThisOrderIDcan then be used in your order records.
Example 2: Randomizing a discount percentage for a promotion
For a marketing campaign, you want to offer customers a random discount between 5% and 20%.
- Inputs:
- Maximum value:
20 - Minimum value:
5 - Variable name:
DiscountPercentage
- Maximum value:
- Result: A new variable named
DiscountPercentageis created, containing a random number between 5 and 20 (e.g.,12). You can then use this variable to calculate the final price for the customer.
Example 3: Assigning a temporary user ID for a survey
When a user starts a survey, you want to assign them a temporary, anonymous ID for tracking purposes.
- Inputs:
- Maximum value:
1000 - Minimum value:
1 - Variable name:
SurveyUserID
- Maximum value:
- Result: A new variable named
SurveyUserIDis created, containing a random number between 1 and 1000 (e.g.,789). This ID can be used to track their progress through the survey without revealing personal information.