Survey Triggers
A trigger adds behaviour to a questionnaire that goes beyond showing, hiding or requiring questions. Each trigger pairs a condition (an expression such as {age} < 18) with an action — for example sending an email, completing the survey, or copying a value into another question.
The questionnaire re-evaluates a trigger’s expression every time one of the questions used in that expression changes. As soon as the expression returns true, the action runs. If a value changes again while the expression is still true, the action runs again.
Triggers are useful when:
- An answer should change the flow of the questionnaire — skipping ahead to a different page, or completing the survey early.
- A value should be calculated, copied or initialised automatically instead of typed by the user — for example stamping a submission date or a report number.
- Something should happen outside the questionnaire when a condition is met — an email to a supervisor when an inspection fails, or a GPS reading when a photo is taken.
- The whole form should be re-validated at a chosen moment, for example after a "confirm" flag is set.
Triggers are stored inside the questionnaire’s JSON design, in a triggers list on the survey itself — not on individual questions.
Where triggers are configured
There are three places in the questionnaire designer where triggers can be viewed and edited:
1. The Logic tab
The Logic tab at the top of the designer lists the survey’s logic rules as If… then… statements. Add a rule, write the condition, and choose the action from the Then dropdown. Five of the trigger types are offered there as actions: Skip to question, Complete survey, Set answer, Copy answer and Run expression.
All triggers — including the email, GPS and validation triggers — can be added and edited in the Triggers table described next. Rules created in the Logic tab also appear in that table; it is the same underlying list.
2. The Triggers table in survey settings
Click on the survey itself — the title area at the top of the page, outside any question — so the property grid on the right shows the survey’s settings. Open the Conditions section: it contains the Calculated values table and the Triggers table.
In the Triggers table, add a row, pick the trigger Type, and fill in the fields for that type. Every trigger has a Name (a label for the trigger) and an Expression (the condition); the remaining fields depend on the type and are described below.
3. The JSON Editor tab
The JSON Editor tab shows the questionnaire definition, including the triggers array. This is useful for copying a trigger between questionnaires or making a bulk edit. A trigger in JSON looks like this:
"triggers": [{
"name": "setSubmissionDate",
"type": "runexpression",
"expression": "{submissionDate} empty",
"runExpression": "today()",
"setToName": "submissionDate"
}]
The type values used in JSON are skip, complete, setvalue, copyvalue, runexpression, gpscapture, email, roleemail, useremail and validatesurvey.
The triggers
Ten trigger types are available in the Triggers table:
| Trigger | What it does |
|---|---|
Skip to question (skip) |
Jumps the questionnaire to the page containing a target question and focuses it. |
Complete survey (complete) |
Completes the questionnaire and shows the "Thank you" page. |
Set answer (setvalue) |
Writes a fixed value into a question, or clears it. |
Copy answer (copyvalue) |
Copies the value of one question into another. |
Run expression (runexpression) |
Evaluates another expression and optionally stores the result in a question. |
Capture GPS coordinates (gpscapture) |
Reads the device’s GPS position into a GPS question when a photo is taken in a camera question, or when a linked expression question turns true. |
Send email to addresses (email) |
Sends an email to a fixed list of addresses. |
Send email to a role (roleemail) |
Sends an email to all mobile users who have a chosen role and access to this questionnaire. |
Send email to users (useremail) |
Sends an email to all back-office users who have Receive mail enabled. |
Validate survey (validatesurvey) |
Runs validation over the whole questionnaire, marking every unanswered required question. |
The names in brackets are the type names as they appear in the questionnaire JSON. In the Triggers table the email and validation triggers are listed under their technical names: emailtrigger, roleemailtrigger, useremailtrigger and validatesurveytrigger.
Skip to question (skip)
Moves the questionnaire to the page that contains the target question and focuses that question. In this system the jump happens as soon as the expression becomes true — the user does not have to press Next first.
| Setting | Purpose |
|---|---|
| gotoName | The question to jump to. The questionnaire navigates to the page containing it. |
{ "type": "skip", "expression": "{sameAsBilling} = 'Yes'", "gotoName": "additionalInfo" }
Complete survey (complete)
Completes the questionnaire and shows the "Thank you" page. Note that in this system the trigger fires as soon as the expression becomes true while the user is answering, rather than waiting for a page change — a complete trigger with {age} < 18 ends the survey the moment an age under 18 is entered. There are no settings beyond the expression.
{ "type": "complete", "expression": "{age} < 18" }
Set answer (setvalue)
Writes a fixed value into a question. This is a declarative alternative to the question’s own setValueIf/setValueExpression properties.
| Setting | Purpose |
|---|---|
| setToName | The question that receives the value. |
| setValue | The value to write. Leave it empty to clear the question. |
{ "type": "setvalue", "expression": "{age} < 18", "setToName": "ageType", "setValue": "minor" }
Copy answer (copyvalue)
Copies the value of one question into another — for example a billing address into a shipping address when the respondent answers Yes to "same as billing".
| Setting | Purpose |
|---|---|
| fromName | The source question to copy from. |
| setToName | The target question to copy into. |
{ "type": "copyvalue", "expression": "{sameAsBilling} = 'Yes'", "fromName": "billingAddress", "setToName": "shippingAddress" }
Run expression (runexpression)
Runs a second expression when the condition is true. This is the most flexible trigger: it is used to initialise fields, keep counters, and calculate derived values.
| Setting | Purpose |
|---|---|
| runExpression | The expression that is evaluated when the condition is true. |
| setToName | Optional. The question that stores the result of runExpression. |
A common pattern in existing questionnaires is an always-true condition such as today() > 0 combined with an iif that only writes the value once — for example, stamping a submission date or report number:
{ "name": "setSubmissionDate", "type": "runexpression", "setToName": "submissionDate",
"expression": "today() > 0",
"runExpression": "iif({submissionDate} empty, today(), {submissionDate})" }
Another real pattern uses two triggers to move a counter up or down as the user presses "left"/"right" marker questions:
{ "name": "Pest right", "type": "runexpression", "setToName": "Qpest",
"expression": "{PestRight} notempty",
"runExpression": "iif({Qpest} empty, 2, iif({Qpest}>=3, 3, {Qpest}+1))" }
Capture GPS coordinates (gpscapture)
Writes the device’s current position (latitude and longitude, to six decimals) into a gpsposition question. In the Triggers table it is listed as Capture GPS coordinates.
| Setting | Purpose |
|---|---|
| Source question | The question that starts the capture. The dropdown lists camera and expression questions. |
| GPS question | The gpsposition question that receives the coordinates. |
How the capture is started depends on the source:
- Camera question. Taking a new photo captures the coordinates — the position where the photo was taken. Deleting the photo clears the coordinates again.
- Expression question. The coordinates are captured when the expression question’s value changes from empty/false to a value — useful when the capture should be tied to any calculated condition rather than a photo.
This trigger reacts directly to the source question — the Expression field on the trigger row is not used and can be left empty.
Two practical notes:
- The browser or device must allow location access. If permission is denied or GPS is unavailable, no value is written; the failure is logged in the browser console.
- The read uses high accuracy and waits up to 30 seconds for a fix, so the coordinates may arrive a moment after the photo.
{ "type": "gpscapture", "sourcename": "fieldPhoto", "setToName": "fieldGps" }
Send email to addresses (email)
Sends an email through the server to a fixed list of addresses. Listed as emailtrigger in the Triggers table.
| Setting | Purpose |
|---|---|
| Email title | The subject line. {question} placeholders are replaced with answers at send time. |
| Email body | The message text, again with {question} placeholders. Sent as plain text. |
| Email address | The recipients, separated by commas. A {question} placeholder can be used to mail an address the respondent entered. |
| From | The sender name shown to the recipient, for example Inspection System. The actual sender address stays the system address. |
| Send email | Ticked: the email is really sent. Unticked: test mode — nothing is sent, but the run is recorded in the Email log. |
All four text fields must be filled before the trigger will run.
{ "type": "email", "expression": "{defectsFound} = true",
"emailtitle": "Defects reported at {farmName}",
"emailbody": "Defects were reported during the inspection at {farmName}.",
"emailaddress": "[email protected]",
"from": "Inspection System",
"sendmail": true }
Send email to a role (roleemail)
Sends the email to all active mobile users that have the selected role and who can access this questionnaire through their mobile user groups — the way to reach, say, every inspector of a certain level when a serious defect is recorded. Listed as roleemailtrigger in the Triggers table.
| Setting | Purpose |
|---|---|
| Email title | The subject line. {question} placeholders are replaced with answers at send time. |
| Email body | The message text, with {question} placeholders. Sent as plain text. |
| Role | The role number of the mobile users to reach — a number from 0 to 9, as set on the Mobile users page. |
| Send email | Ticked: the email is really sent. Unticked: test mode — nothing is sent, but the run is recorded in the Email log. |
Because the recipients are resolved through the questionnaire’s registration, this trigger only works when the questionnaire was opened through a registration. Without a registration the server returns "Could not find registration for this survey".
{ "type": "roleemail", "expression": "{safetyIssue} = true", "role": 2,
"emailtitle": "Safety issue at {farmName}",
"emailbody": "A safety issue was reported at {farmName} by {inspectorName}.",
"sendmail": true }
Send email to users (useremail)
Sends the email to every back-office user that has Receive mail enabled on their account — the people who opted in to notifications. Listed as useremailtrigger in the Triggers table.
| Setting | Purpose |
|---|---|
| Email title | The subject line. {question} placeholders are replaced with answers at send time. |
| Email body | The message text, with {question} placeholders. Sent as plain text. |
| Send email | Ticked: the email is really sent. Unticked: test mode — nothing is sent, but the run is recorded in the Email log. |
{ "type": "useremail", "expression": "{inspectionFailed} = true",
"emailtitle": "Failed inspection at {farmName}",
"emailbody": "The inspection at {farmName} was marked as failed.",
"sendmail": true }
Validate survey (validatesurvey)
Runs the questionnaire’s full validation — the same pass that happens on Complete — without completing it. Every required-but-unanswered or invalid question gets flagged with its error message. Listed as validatesurveytrigger in the Triggers table; there are no settings beyond the expression.
A typical use is a "finalise" flag: a requiredIf expression makes the signature and key questions required only once {finalised} = true, and a validate trigger on the same flag forces all outstanding errors to show immediately instead of only at submit time.
{ "type": "validatesurvey", "expression": "{finalised} = true" }
Test mode and the Email log
The three email triggers share the same Send email checkbox. Leave it unticked while building: the trigger still runs, the server resolves the recipients, and the whole attempt is recorded on the Email log page — with Send set to false, the message "test mode: N emails", and the recipient list in the Log column. This is the way to check who would have received the email before switching it on. Every real send is logged there too, so the page doubles as an audit trail for trigger emails.
When an email trigger fires, a toast in the corner reports success ("3 emails sent") or the reason it failed ("no mobile users found").
Basic examples
Example 1: email the office when an inspection fails
An inspection questionnaire has a defectsFound boolean and a farmName question. The maintenance office should get an email whenever defects are flagged.
- Open the questionnaire in the designer, click on the survey title area, and open the Conditions section of the survey settings.
- In the Triggers table, add a row and set Type to emailtrigger.
- Name: defectAlert. Expression:
{defectsFound} = true. - Email title: Defects reported at {farmName}.
- Email body: a short message, e.g. Defects were reported during the inspection at {farmName}. Please review the submission.
- Email address: the maintenance mailbox (or several, comma-separated).
- From: Inspection System.
- Leave Send email unticked, save, and test the questionnaire: tick the defects flag and check the Email log page for a test mode: 1 emails entry with the right recipient. Then tick Send email to go live.
Example 2: store the GPS position where a photo is taken
A field questionnaire has a fieldPhoto camera question and a fieldGps GPS question. Each photo should carry the coordinates of where it was taken.
- In the Triggers table, add a row and set Type to Capture GPS coordinates.
- Source question: fieldPhoto. GPS question: fieldGps. Leave the expression empty.
- Save. In the questionnaire, taking a photo fills fieldGps with the device position; deleting the photo clears it.
Example 3: alert a role group when a safety flag is set
A safetyIssue boolean should notify every field supervisor (role 2) who can access the questionnaire.
- Add a Triggers row with Type roleemailtrigger.
- Expression:
{safetyIssue} = true. Role: 2. - Fill title and body with placeholders, for example Safety issue at {farmName} reported by {inspectorName}.
- Test with Send email unticked — the Email log shows how many supervisors would be reached — then switch it on.
Things to know
- Triggers re-run. A trigger evaluates again each time a question in its expression changes — and if the expression is still true, the action runs again. An email trigger on
{defectsFound} = truesends a mail every time the flag is set, so design expressions that flip once (a finalise flag, a status change) rather than conditions that stay true while the user edits other answers. - Email triggers react to answers, not navigation. They run when a value used in the expression changes, not when the user moves to the next page or completes the survey.
- Expressions use the same syntax as elsewhere.
{name}references a question, with operators like=,<>,>,empty,notempty,and,or, and functions such asiif(),today(),getUser(),getRegvalue()andgetDistancebetweencoords(). - The Name field is just a label. It helps identify the trigger in the list and in the JSON; it has no effect on behaviour.
- Triggers are not visibility rules. For showing/hiding or requiring questions, use visibleIf, enableIf and requiredIf on the question itself — those stay correct as values change, while a trigger only performs its action once per change.
- Different from Action rules. Triggers run inside the questionnaire while someone fills it in. Action rules are the server-side jobs that run on a daily schedule and create action items — see the Action Rules tutorial.
- Different from the dynamic loader. The Trigger dynamic loader checkbox on expression questions is a separate feature that loads extra questions into the form at runtime; it is unrelated to the triggers described here.