A Number field can be a formula that performs a calculation. Formulas can reference other Number fields. Formulas are configured in the default or static value for a Number field.
Note: You can configure formulas in your template, but your API request can only contain numbers.
Operators and Functions
- All functions from Ruby's Math module, including
Formulas use the following syntax for referencing field names:
- Object keys are separated by a period (
- Array indices are wrapped with square brackets (
The following table shows how to convert between the JSON Pointer syntax, and formula references:
|JSON Pointer||Formula Field Name|
(We need to use a different syntax because
/is the division operator in formulas.)
You may want to split up a calculation into multiple steps, or re-use the result of one calculation in multiple places. You can do this by creating a Number field that is both Static and Hidden.
This field will function as an intermediate "variable" that can be referenced by other formulas, but it will not be part of the API schema, and it is not displayed on the PDF.
Here's an example template that demonstrates a number of different features.
|Field Name||Required?||Static?||Default or Static value|
bare both required fields.
bmust be an array that contains two numbers.
cis not provided, the default formula will calculate the maximum value from the
dis a static field, and can only be computed from the other fields.
dis not part of the API.
Given the following values:
a => 7
b => [12, 15]
c => null
The generated PDF will show the following results: