TwinaForms Help
Writing formulas in TwinaForms.
Formulas compute a field's value live as users fill the form — from simple concatenations like a full name, to totals, date math, and conditional messages. This page is a practical reference with copy-paste examples.
Where formulas work
Turn any Text or Number field into a formula field from the Designer's Element Properties panel. The field becomes read-only in the published form and recomputes every time a source field changes.
- Recalculates live as the user types.
- Submits the computed value to Salesforce along with everything else.
- Formulas can reference input fields, but not other formula fields (no formula‑to‑formula chains in v1).
- Not yet available inside repeat groups.
Syntax basics
Field references
Wrap a field's Internal Name (ID) in curly braces. Internal IDs are auto-generated and look like text2, number4, email5, checkbox11, radio10 — not the friendly label you typed.
{text2}
{number4}
{checkbox11}
You don't have to type them. In the formula editor use the Insert field dropdown (the list shows each field's friendly label with its internal ID in parentheses) and click Insert — the correct reference is placed at the cursor.
Literals
- "Hello" — string (double quotes).
- 42, 3.14, -1 — numbers.
- true, false — booleans.
Function calls
Function names are uppercase. Arguments are separated by commas.
IF({isVip}, "Priority", "Standard")
CONCAT({firstName}, " ", {lastName})
❌ IF({status} = "Open", "Yes", "No")
✅ IF({status} == "Open", "Yes", "No")
Operators
Arithmetic
{quantity} * {unitPrice}
({subtotal} + {tax}) - {discount}
Comparison
String comparisons are case-sensitive. Use IF({rating} == "Hot", …) with the exact picklist value.
Logical
IF({total} > 100 and {isMember}, "Member discount", "")
Examples
Copy, paste into a Text or Number formula field, and replace the field references with yours.
Full name from two fields
Text formula. Uses CONCAT so "John" + " " + "Doe" becomes "John Doe".
CONCAT({firstName}, " ", {lastName})
Line total
Number formula. Multiplies quantity by unit price.
{quantity} * {unitPrice}
Line total with tax, rounded to cents
Number formula. The outer ROUND keeps the result to two decimals.
ROUND({quantity} * {unitPrice} * 1.17, 2)
Equality check — IF(A == B, …)
Text formula. Compare a field to a literal value using ==. String comparisons are case‑sensitive, so match the exact picklist or input value.
IF({rating} == "Hot", "Contact today", "Regular follow-up")
VIP greeting
Text formula. Shows a personalized line only for members.
IF({isMember},
CONCAT("Welcome back, ", {firstName}, "!"),
CONCAT("Hello, ", {firstName}))
Default to "N/A" when a field is empty
Text formula. COALESCE returns the first non-blank argument.
COALESCE({nickname}, {firstName}, "N/A")
Age from a date of birth
Number formula. Approximate age using year difference.
YEAR(TODAY()) - YEAR({dateOfBirth})
Discount band
Text formula. Nested IF forms a simple tiered rule.
IF({orderTotal} >= 1000, "Gold",
IF({orderTotal} >= 500, "Silver",
IF({orderTotal} >= 100, "Bronze", "Standard")))
Shipping fee rule
Number formula. Free shipping above $100, otherwise flat $9.90.
IF({orderTotal} >= 100, 0, 9.90)
Case reference
Text formula. Builds a unique-looking id the user can quote in support.
CONCAT("REF-", YEAR(TODAY()), "-", {email})
Limits & gotchas
- String comparisons are case-sensitive. "Hot" == "hot" is false.
- Empty fields become null, not an empty string. Wrap with COALESCE({field}, "") if you need a safe default.
- Dates are browser-local. A user in Tel Aviv and one in New York can see different TODAY() values for a few hours each day.
- No formula-to-formula references. If you need a nested calculation, inline it in a single expression.
- No support inside repeat groups yet. Place formulas on top-level fields only.
- Formula fields ignore prefill. The source fields prefill normally and the formula recalculates from them.
- Invalid input returns null. VALUE("hello") is blank, not zero.