The Formular field is designed to execute JSON Logic expressions and return a computed value. Instead of hard-coding formulas, administrators write JSON Logic directly referencing other field values, performing calculations, string concatenation, conditional checks, and more. It’s ideal for situations such as:
- Auto-generating unique submission names or codes;
- Populating hidden flags or derived data (e.g., if a score ≥ 80, set passed to true);
- Any scenario where one field’s value depends on one or more other inputs.
Wherever logic is required either being math, string operations, boolean checks; the Formular field handles it via JSON Logic.
To add a Formular field to your submission form:
- Open the form builder and click Add Field, then choose Formular.
- Give the field a Subject (e.g., “Submission Name Generator”).
- Optionally set a Description, such as “Generates a unique submission name automatically.”
Click Edit Formular to open the JSON Logic editor. For example, to generate a name starting with CALL2025-, taking the first three characters of the title field, appending a hyphen, and including the weekday of the dateBegin field, use:
{
"upperCase": [
{
"cat": [
"CALL2025-",
{
"substr": [{ "var": "title" }, 0, 3]
},
"-",
{
"weekDay": [{ "var": "dateBegin" }]
}
]
}
]
}
In this JSON Logic:
var references other fields "title" and "dateBegin"
substr takes a substring of title from index 0 to 3
weekDay returns the weekday number (0–6) of dateBegin
cat concatenates fragments
upperCase converts the result to uppercase.
- Choose whether the field should be Visible or Hidden. Computed fields are often hidden since they serve downstream processes.
- Save the field. The form builder validates the JSON Logic syntax and alerts you to errors; fix any issues before saving. Once saved, each new submission will receive a unique name based on this logic.
Using JSON Logic for Calculations and Strings
JSON Logic is a lightweight, tree-structured way to express logic. Common patterns include:
Basic arithmetic:
{"+": [ { "var": "quantity" }, { "var": "bonus_units" } ]}
Adds two numeric fields.
Conditional checks:
{
"if": [
{ ">": [ { "var": "score" }, 90 ] },
"A+",
{ ">": [ { "var": "score" }, 80 ] },
"A",
"Needs Improvement"
]
}
Returns a letter grade based on score.
String concatenation:
{"+": [ "Hello, ", { "var": "first_name" }, "!" ]}
Produces “Hello, John!” if first_name=“John.”
Nested logic:
{
"if": [
{ "and": [
{ "==": [ { "var": "country" }, "US" ] },
{ "==": [ { "var": "state" }, "CA" ] }
] },
"California Order",
"Other State"
]
}
Checks multiple fields and returns a custom string.
Since the Formular field evaluates logic on every render and on submit, ensure you only include existing fields. Misspelling a field key will cause a null result. Always test your logic in preview mode.
Tips and Best Practices
Below are a few pointers to make the most of your Formular fields:
- Reference exact field keys; JSON Logic is case-sensitive. If your field key is order_total, using Order_Total will return null.
- Keep logic modular; for complex formulas, consider breaking them into multiple hidden Formular fields and then combining results in a final field. This simplifies debugging.
- Test thoroughly by using preview mode and sample data. Confirm that edge cases (zero values, blank fields) return sensible results rather than null or NaN.
- Use descriptive field labels so admins know why that Formular exists. Even if it’s hidden, the label helps future maintainers.
- Validate inputs on numeric fields before referencing them in Formular. Non-numeric text in a numeric field can break calculations. Use built-in validation rules on those fields.
- Document your JSON Logic in the field’s description—admins can understand how it works without diving into the editor. A brief note like “Generates submission name using CALL2025 and image dialogue” is helpful.
- Handle errors gracefully; if nothing renders in preview or on submit, inspect your JSON Logic for syntax or reference issues.