Skip to main content

MOD

Use the MOD function to obtain the remainder when one number (numerator) is divided by another number (divisor).

Use​

MOD( numerator, divisor )
Returns the remainder after division.

ParameterRequiredDescription
numeratorYesthe number to be divided by the divisor
divisorYesthe number to divide numerator by

ReturnsNumber

Examples​

Load Balancing (Path Conditions)​

You can use the MOD function in a Path Condition Formula within a Branch step to alternate or rotate approval runs between different teams or individuals.

  • Scenario: You want to split incoming requests equally between two different review teams (Team A and Team B) based on the sequential run number.
  • Formula (for Team A's Path): MOD(@prop.RunNumber, 2) = 1
  • Formula (for Team B's Path): MOD(@prop.RunNumber, 2) = 0
  • Logic:
    • @prop.RunNumber: This system property provides the unique sequential number of the current approval run.
    • Calculation: If Run #101 is processed, MOD(101, 2) equals 1, so it follows Team A's path. If Run #102 is processed, MOD(102, 2) equals 0, so it follows Team B's path. This ensures an even distribution of work.

Order Quantity Validation (Output Validation)​

In the Form Builder, you can use MOD within an Output Validation Formula to ensure that a user enters a numeric value that is a multiple of a specific set (such as a batch size or a dozen).

  • Scenario: A company sells items in "Packs of 6." You want to ensure the "Quantity" entered by a user is a multiple of 6 to prevent shipping errors.
  • Formula: ASSERT(MOD(this, 6) = 0, "Items must be ordered in multiples of 6.")
  • Logic:
    • this: Refers to the numeric value currently being entered in the capture widget.
    • MOD(this, 6): This checks if there is any remainder when the input is divided by 6.
    • Result: If a user enters 12, the remainder is 0 (TRUE), and the form is valid. If a user enters 10, the remainder is 4 (FALSE), and the ASSERT function triggers the custom error message.