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.
formName
string
The name of the form
formId
string
The ID of the form
userId
string
The ID of the user in the current form session
fields
{ [fieldKey: string]: Field }
getStepProperties
() => { totalSteps: number, stepName: string, previousStepName: string, backgroundColor: hex string, language?: string, hideRules: { elementType: string; rules: {}[] } }
Returns useful information about the current step of the form:
Name of current step
Name of previous step
Background color of step
Total steps in form
Language code of form if set
Conditional hide/show rules on step
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.
runAIExtraction
(extractionId: string, options: {waitForCompletion?: boolean, pages?: number[], variantId?: string})
Trigger an AI document extraction.
If waitForCompletion
is true, the returned Promise will resolve with data from the last action once it completes. Otherwise, it will return immediately with no data.
If variantId
is specified, the extraction will run with that variant applied.
updateUserId
(userId: string, merge?: boolean) => void
setCalendlyUrl
(url: string) => void
openUrl
async (url: string, target?: string) => void
Flush any pending field updates and then opens up a URL.
cart
products
Last updated
Was this helpful?