DECIMALS
Use the DECIMALS function to determine the number of decimal places in a Number.
Use
DECIMALS( number )
Returns the number of decimal places in the given number.
| Parameter | Required | Description |
|---|---|---|
| number | Yes | the number to count decimal places of |
| Returns | 'Number' |
Examples
Enforcing Currency Precision
In financial workflows, such as an expense claim, you may need to ensure that a user enters an amount with exactly two decimal places for cents. You would apply this as an Output Validation Formula on a "ClaimAmount" field.
- Formula:
DECIMALS(this) = 2 - Logic: The formula checks the output value (
this) and returns TRUE only if there are exactly two digits after the decimal point. If a user enters "50" or "50.1", it would return FALSE (invalid); if they enter "50.00", it returns TRUE (valid).
Disallowing Decimal Numbers (Whole Numbers Only)
If an approval requires a quantity of items (e.g., a hardware request for laptops), you can use the DECIMALS function to ensure the user does not enter a fraction.
- Formula:
DECIMALS(this) = 0 - Logic: By setting the required count to zero, the formula ensures the number is a whole integer. Any entry containing a decimal point with trailing digits (e.g., "1.5") would result in FALSE, marking the field as invalid on the form.