LogoLogo
Back to studio
  • 🧠Core Concepts
    • Introduction to Formsort
    • Formsort quickstart guides
      • Add content and collect answers
      • Capture demographic data
      • Add informational content
      • Template your variables
      • Add conditional logic
      • Using conditional logic with Calculated and API variables
      • Add a scheduling option
      • End the flow
      • Review your variable schema
      • Set up integrations
    • How data works in Formsort
      • Responder UUIDs
    • Understanding flows
    • Versioning in Formsort (Deploying)
      • Variant revisions
      • Managing revisions
  • ✨Creating Flows
    • Building a new flow
      • Groups
      • Steps
      • Copy-pasting form content
  • Adding questions and content
    • Questions
      • Select
      • Text
      • Address
      • Comparison
      • Confirmation
      • Date
      • Date & time
      • Email address
      • File upload
      • Grid choice
      • Iframe
      • Image upload
      • Number
      • Payment
      • Phone number
      • Postal code
      • Question group
      • Region
      • Signature
      • SSN
      • Yes/No
    • Content
      • Statement
      • Image
      • Next button
      • Video
      • Divider
      • Map
  • Controlling the flow with conditions and logic
    • Advanced logic
  • Variable templating
  • Redirects and endings
  • Field validation
  • Flow and variant management
  • Content library
  • 🧬JSON Form Definition
  • JSON schemas
  • Validating flow schemas
  • Events subscriptions
  • Flow content data format
  • 🎨Styling
    • Customizing appearance
      • Content area & form layout
      • Buttons
      • Typography
      • UI states
      • Color and dimension variables
      • Question containers
      • Inputs and dropdowns
      • Checkmarks
      • Tables
      • Sliders
      • Divider lines
      • Progress bar
      • Comparison cards
      • Animations and transitions
  • CSS & Advanced Styling
    • Custom CSS overrides
    • Step styling
    • CSS reference
  • 🔁Form Behavior Settings
    • Variant settings
      • Form behavior for returning users
      • Group ranking API
    • Navigation sidebar
  • ⚙️Response Data Collection & Management
    • Schema (variables)
      • Variables from questions
      • Externally provided variables
      • Calculated variables
      • API lookups
      • System Library variables
      • Orphaned variables
  • Saving & retrieving responses
  • Importing Data
    • URL parameters
    • POST body
    • Embed query parameters
  • 📊Analytics and Attribution
    • Built-in analytics
    • Split testing
  • 🚀Publishing and Deployment
    • Live preview overview
    • Environments
      • Loading different environments
    • Embedding
      • Web-embed API
        • React-embed
      • Adding authentication
      • Embedding forms in iOS and Android
      • Setting up a dev environment
    • Pre-deployment checklist
  • 📁Workspace Management
    • Accounts
      • Roles and permissions
    • Custom domains
    • Workspace domain detection
  • 🛠️Formsort Admin API
    • Admin API
  • 🔌Integrations
    • Form answers and events
      • Analytics events
      • Signed requests
      • Event payload shape
      • Submission frequencies
      • Runtime error reporting
    • Integration reference
      • Amplitude
        • Amplitude cross domain tracking
      • BigQuery
      • FullStory
      • Google Analytics
        • Updating from Universal Analytics to GA4
      • Google Cloud Storage
      • Google Sheets
      • Google Tag Manager (GTM)
        • JavaScript triggered by flow events
      • Hubspot
      • Jornaya
      • Optimizely
      • PostgreSQL
      • Redshift
      • Rudderstack
      • S3
      • Salesforce
      • Segment
        • Segment Setup
        • Segment cross domain tracking
      • Stripe
      • TrustedForm
      • Webhooks
        • Zapier
Powered by GitBook
On this page

Was this helpful?

  1. Controlling the flow with conditions and logic

Advanced logic

PreviousControlling the flow with conditions and logicNextVariable templating

Last updated 10 days ago

Was this helpful?

Enabling Advanced logic allows you to write custom boolean expressions using , giving you full flexibility over conditional rendering in your flow.

Instead of using a visual logic builder, you write logic directly in JSON format. Each answer variable maps to a field, and standard MongoDB query operators evaluate those fields.

Why JSON, not Drag-and-Drop?

While we may support a visual builder in the future, the JSON-based syntax is:

  • Powerful and expressive

  • Lightweight and easy to copy/paste

  • Flexible enough for most complex logic needs

Common patterns

Both conditions must be true — $and

Enable an item only if both conditions are satisfied:

  • distance_to_office is less than or equal to 75

  • is_qualified is true

{
  "$and": [
    {
      "distance_to_office": {
        "$lte": 75
      }
    },
    {
      "is_qualified": true
    }
  ]
}

At least one condition is true - $or

Enable an item if either of the following is true:

  • is_parent is true

  • has_parent_consent is true

{
  "$or": [
    {
      "is_parent": true
    },
    {
      "has_parent_consent": true
    }
  ]
}

Answer is one of several values — $in

Check if an answer matches any value from a list.

Enable if country is CA, MX, or US:

{
  "country": {
    "$in": [
      "CA",
      "MX",
      "US"
    ]
  }
}

Answer is not in a list of values — $nin

Check that an answer does not match any value from a list.

Enable if state is not NY or PA:

{
  "state": {
    "$nin": [
      "NY",
      "PA"
    ]
  }
}

Answer is defined — $exists

Enable if a variable has any value (even false):

{
  "income": {
    "$exists": true
  }
}

This mirrors the behavior of the Is defined simple logic operator.

Read more about .

Read more about .

Read more about .

Read more about .

Read more about .

MongoDB’s query and projection operators
$and
$or
$in
$nin
$exists