Script functions
Reading the form
| Function | Gives you |
|---|---|
value('key') | The answer in another field. You can also write key() — every field is callable by its own key. |
parent('key') | An answer on the enclosing record. Only inside a repeatable section or a subform entry; anywhere else it raises an error. |
rows('section') | A repeatable section’s rows, as an array of objects. Empty array if none. |
user() | Who is filling the form in: { id, name, email }. |
isBlank(v) | True for null, undefined, whitespace-only text and empty arrays. |
Arithmetic
| Function | Does |
|---|---|
SUM(...) | Adds everything given. Non-numbers are ignored. |
AVG(...) | Mean. 0 when there is nothing to average. |
MIN(...), MAX(...) | Smallest and largest. null when given nothing. |
COUNT(...) | How many values are filled in. Flattens arrays; skips null, undefined and empty text. |
ROUND(n, places) | Rounds. places defaults to 0. null if n is not a finite number. |
Math | PI, E, abs, ceil, floor, round, sqrt, pow, min, max. |
Dates, conversion and objects
| Function | Gives you |
|---|---|
TODAY() | Today as YYYY-MM-DD. |
NOW() | The current moment as an ISO 8601 string. |
Number(v), String(v), Boolean(v) | Conversion. String(null) gives ''. |
parseInt(v, radix), parseFloat(v), isNaN(v) | As expected. radix defaults to 10. |
Object.keys(o), Object.values(o) | For walking a repeatable row. [] for anything not an object. |
The language
Ordinary JavaScript expressions and statements: const and let, if,
for, for…of, while, arrow functions, template literals, optional
chaining, ??. Not available: anything that reaches outside the form —
fetch, window, document, localStorage, import.
A field whose key collides with a function name — a field called sum, say
— does not get the sum() shorthand. The function wins, and you read that
field with value('sum').
What each kind of script should return
| Kind | Return |
|---|---|
| Value | the value to write into the field |
| Condition | truthy to show the field, falsy to hide it |
| Validation | true if acceptable; a string to reject with that message; false to reject with a generic one |