Comment on page
Advanced logic
Using arbitrary boolean logic within forms.
With Advanced logic checked, you may enter logic using the MongoDB Query and Projection operators, allowing entry of arbitrary boolean logic.
Your answer variable names map to fields, and the standard query operators are used to evaluate them.
Why no drag and drop advanced logic editor?
We might build one some day, but we've found that using the JSON syntax of MongoDB is very flexible, easy enough to learn, and fully captures the needs of most form flows.
The following condition would only be enabled when two conditions are both true:
- a variable named
distance_to_office
is less than 75 - a variable named
is_qualified
is true
{
"$and": [
{
"distance_to_office": {
"$lte": 75
}
},
{
"is_qualified": true
}
]
}
The following condition would be enabled when either of two conditions are both true:
- a variable named
is_parent
is true - a variable named
has_parent_consent
is true
{
"$or": [
{
"is_parent": true
},
{
"has_parent_consent": true
}
]
}
It's possible to use
$or
to check for whether an answer equals any of a set of conditions, but it's easier to read if you use $in
to check whether an answer matches any of a set of values.The following condition would be enabled when a variable named
country
is CA
, MX
or US
:{
"country": {
"$in": [
"CA",
"MX",
"US"
]
}
}
To check that an answer is not one of a set of possible values, you can use
$nin
. The following condition would be enabled when a variable named
state
is not NY
or PA
.{
"state": {
"$nin": [
"NY",
"PA"
]
}
}
The following condition would be enabled when a variable named
income
has any value:{
"income": {
"$exists": true
}
}
Last modified 2mo ago