Context API

Common API functionality across advanced logic, event handlers, and the context ref.

All of these properties are available via advanced logic, event handlers, and the contextRef object. Specific events may also have additional properties unique to them. To see these properties, check out the documentation for the corresponding event handler.

KeyTypeDescription

userId

string

The ID of the user in the current form session

fields

{ [fieldKey: string]: Field }

A mapping that contains all fields on any of your forms. Its key is the field ID and value is a Field object. Use the Field object to read/write a field value, options, error message, etc.

getStepProperties

() => { totalSteps: number, stepName: string, previousStepName: string, backgroundColor: hex string, language?: string }

Returns useful information about the current step of the form, including its name, the name of the previous step, the background color of the step, and the total number of steps in the form. Also returns the language code of the form if it was explicitly set.

goToStep

function

If you want to reroute the user to a different step, pass goToStep the ID of the new step to route to. For example, goToStep('new-step')

setProgress

(number | { progress?: number; segments ?: number }) => {}

Set the amount of the progress bar on the current step.

Pass in either a number from 0 - 100 or if you want a segmented progress bar, you can pass in both the progress amount and the number of segments you want the progress bar to be broken into.

setFormCompletion

function

Pass in a boolean flag to set the user's completion status for this form.

validateStep

(showErrors = true) => { [fieldKey: string]: string | string[] }

Runs default form validation on the current step. Triggers built-in field validation along with custom validation rules specified from the dashboard. Errors will be shown unless false is passed for showErrors.

Returns an error message per field, or an empty string if the field is valid.

isLastStep

() => boolean

Returns True when the current step is the last step the user needs to complete.

isTestForm

() => boolean

Returns True when the current form is in test mode (and not live).

collaborator

Information about the active collaborator.

runIntegrationActions

(actionIds: string[] | string, options: {waitForCompletion?: boolean; multiple?: boolean}) => Promise<{ ok: boolean; error?: string; payload?: any }>

Trigger integration actions that have been set up with the Custom Logic trigger. If multiple actions are passed, they will be run in order.

If waitForCompletion is true (the default), the returned Promise will resolve with data from the last action once it completes. Otherwise, it will return immediately with no data. If multiple is true (defaults to false), you may trigger the same action multiple times for a single submission.

updateUserId

(userId: string, merge?: boolean) => void

Update the user ID of the current session. Full reference

setCalendlyUrl

(url: string) => void

If a Calendly scheduling flow is embedded in your form, you can dynamically update the calendar by calling this function and passing in a new Calendly URL.

openUrl

async (url: string, target?: string) => void

Flush any pending field updates and then opens up a URL.

cart

If the Stripe connector is configured and connected, then the purchase cart is available with a number of properties about the cart and items within it. See here for details.

products

{ [product_id: string]: Products }

If the Stripe connector is configured and connected, then the purchasable products are available as a hash. See here for details.

Last updated