LogoLogo
Back to studio
  • Formsort documentation
  • โฉQuickstart
    • ๐ŸŸขGet started with Formsort
    • ๐ŸŽCore concepts
    • โ„น๏ธQuestion and content reference
    • ๐Ÿ“•Key terms
    • ๐Ÿž๏ธCreate your first flow
    • ๐Ÿ“–Add content and collect answers
      • ๐ŸคณCapture demographic data
      • โ„น๏ธAdd informational content
      • ๐Ÿ” Review your variable schema
    • ๐ŸŽจCreate a theme
      • Set brand guidelines
    • ๐ŸคนPersonalize your flow
      • ๐ŸŒŸTemplate your variables
      • ๐Ÿง Add conditional logic
      • ๐Ÿ’ซUsing conditional logic with Calculated and API variables
      • ๐Ÿ”šEnd the flow
    • ๐Ÿ”€Set up integrations
    • ๐Ÿš€Go live
      • Auditing your flow for content, functionality, and design
    • ๐Ÿ’ผCommon use cases
      • ๐Ÿ’”Disqualify responders
      • ๐Ÿ—“๏ธAdd a scheduling option
      • ๐Ÿ“„Allow responders to read and accept your company policies
  • ๐Ÿ—๏ธBuilding flows
    • Flows and variants
      • Flow starts
    • Adding content
      • Groups
      • Steps
        • Settings
        • Logic
        • Style
      • Questions
        • General Settings
        • Style
        • Address
        • Comparison
        • Confirmation
        • Date
        • Date & Time
        • Email address
        • File upload
        • Grid choice
        • Iframe
        • Image upload
        • Number
        • Payment
        • Phone number
        • Postal code
        • Question group
        • Region
        • Select
          • Providing choices via API or calculation
        • Signature
        • SSN
        • Text questions
        • Yes/No
      • Content
        • General Settings
        • Statement
        • Image
        • Video
        • Next button
        • Divider
        • Map
      • Endings
      • Using markdown
      • Using variable templating
        • Template formatting functions
      • Copy-pasting form content
      • Content library
    • Conditions and logic
      • Logical operator reference
      • Advanced logic
    • Variables (answers)
      • Variables from questions
      • Externally provided variables
      • Calculated variables
      • API lookups
      • System Library variables
      • Orphaned variables
    • Schemas
      • JSON Schemas
      • Validating flow schemas
    • Redirects
    • Styling and themes
      • CSS Reference
      • Overriding theme styling
      • Custom CSS overrides
      • Content area
      • Animations and transitions
      • Form Layout
      • Typography
        • Adobe Fonts
        • Hosting custom fonts
      • Color variables
      • Dimension variables
      • Question containers
      • Assets
      • Form Buttons
        • Select buttons
      • Inputs and dropdowns
      • Checkmarks
      • Tables
      • Sliders
      • Divider lines
      • Progress bar
      • Comparison cards
    • Variant settings
      • Form behavior for returning responders
      • Group ranking API
    • Publishing and versions
      • Preview window
      • Deploying
      • History
  • ๐Ÿ’พHandling data
    • Philosophy and data retention policy
    • Viewing form answers
    • Responder UUIDs
    • Environments
      • Loading different environments
    • Passing data in
      • URL parameters
      • POST body
      • Embed query parameters
    • Custom validators
    • Form answers and events
      • Analytics events
      • Signed requests
      • Event payload shape
      • Submission frequencies
      • Runtime error reporting
      • Admin API
      • Flow content data format
    • 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
  • ๐Ÿ“บGoing live
    • Custom domains
    • Built-in analytics
    • Embedding
      • Web-Embed API
        • React-embed
      • Adding authentication
      • Embedding forms in iOS and Android
      • Setting up a dev environment
    • Split testing
    • Preflight checklist
  • ๐ŸขTeams
    • Accounts
      • Roles and permissions
    • Events subscriptions
    • Workspace domain detection
Powered by GitBook
On this page
  • Choice schema
  • Configuring an API lookup or calculation
  • External API
  • Calculated locally

Was this helpful?

  1. Building flows
  2. Adding content
  3. Questions
  4. Select

Providing choices via API or calculation

Dynamically loading select choices

PreviousSelectNextSignature

Last updated 4 years ago

Was this helpful?

Standard have a discrete set of choices to select from that are defined at the time that the form is created. If the list of choices to present to your responders isn't known at the time the form is being built, or changes often, it's possible to load choices dynamically, from an API lookup or calculation.

Trying to look up an answer from an API? See .

See comparing different approaches to specifying choices for a visual walkthrough.

Choice schema

Dynamically-loaded choices, whether from an API or calculated locally, must adhere to the following format:

[
  {
    "label": "The first choice", // Displayed to the user
    
    "value": "choice_a",         // Stored in the answers
    
    "disabled": false,           // [Optional]: Whether the choice
                                 // is disabled
                                 
    "imageUrl": "https://..."    // [Optional]: If loading choices
                                 // for a select question with
                                 // images, the URL of the image.
  }
] 

Configuring an API lookup or calculation

With a select question selected, go to the CHOICES tab, and select Load choices dynamically.

External API

With External API selected, you will be able to configure an API lookup from which values will be retrieved.

If the API you are connecting to does not return results of the form described in the schema above, you can use a result mapping function to transform the result.

Calculated locally

When calculated locally is enabled, you will be able to use Typescript to output the answers for responder.

For example, the following definition would create ten days of future dates as choices.

function myFunction(): IChoice<string>[] { // readonly line

  const date = new Date();
  const choices: IChoice<string>[] = [];
  const numDays = 10;
  for (let i = 0; i < numDays; i++) {
      date.setDate(date.getDate() + 1)
      choices.push({
          label: date.toDateString(),
          value: date.toISOString()
      })
  }
  return choices;
}

See for more on how to specify API lookups.

See for more information on writing calculated answers inline.

๐Ÿ—๏ธ
select questions
API answers
this video
API answers
calculated answers