Elevate your document automation in Docdown using formulas and functions. Functions allow you to adjust your document's content dynamically based on specific criteria.
Available Functions
These are some advanced pre-defined functions you can use with your field values in the formula section of the document editor.
Function Name | Description | Parameters | Example Usage |
---|---|---|---|
|
|||
random(n) | Generates a random number within the range [0, n). | n: upper limit (optional, default=1) |
random(10)
|
n! | Calculates the factorial of n. | n: number |
5!
|
min(a,b,…) | Identifies the smallest number in a given list. | a, b, …: list of numbers |
min(3, 7, 1)
|
max(a,b,…) | Identifies the largest number in a given list. | a, b, …: list of numbers |
max(3, 7, 1)
|
hypot(a,b) | Calculates the hypotenuse or the square root of the sum of the squares of its arguments. | a, b: sides of a right triangle |
hypot(3, 4)
|
pyt(a, b) | Alias for hypot, calculates the hypotenuse. | a, b: sides of a right triangle |
pyt(3, 4)
|
pow(x, y) | Raises x to the power of y. | x: base, y: exponent |
pow(2, 3)
|
atan2(y, x) | Calculates the arc tangent of x/y, the angle in radians between (0, 0) and (x, y). | y: width, x: height |
atan2(90, 15)
|
roundTo(x, n) | Rounds x to n decimal places. | x: number to round, n: number of decimal places |
roundTo(3.14159, 2)
|
map(f, a) | Applies function f to each element in array a, returning an array of the results. | f: function, a: array |
map(f, [1, 2, 3])
|
fold(f, y, a) | Reduces array a into a single value y by applying function f to each element. | f: function, y: initial value, a: array |
fold(f, 0, [1, 2, 3])
|
filter(f, a) | Filters array a by function f, returning an array of elements for which f is true. | f: function, a: array |
filter(f, [1, 2, 3, 4])
|
indexOf(x, a) | Finds the first index of value x in array a; returns -1 if not found. | x: value, a: array |
indexOf('Invoice', ['Report', 'Invoice', 'Memo'])
|
join(sep, a) | Joins the elements of array a into a string, separated by sep. | sep: separator, a: array |
join("; ", ['Report', 'Invoice', 'Memo'])
|
if(c, a, b) |
Evaluates condition c; returns a if true, b otherwise. Note: always evaluates both a and b. |
c: condition, a: value if true, b: value if false |
if(x>10, 'High', 'Low')
|