Writing Custom Code in Embeddables
How to get the most out of custom code blocks in Embeddables
Custom Code blocks in Embeddables are where you can escape the confines of no-code and create entirely custom functionality.
Custom Code exists in two main places: Computed Fields and Actions.
Available arguments in Custom Code functions
Custom Code blocks provide various bits of context through arguments in the root functions. They are, in order:
# | Argument | Description |
---|---|---|
1 | userData | The current User Data |
2 | helperFunctions | An object containing various helper functions (see full list below) |
3 | triggerContext | An object containing data on what triggered the Computed Field or Action (see full list below) |
Helper Functions
The following helper functions are available in both Computed Fields and Actions through the helperFunctions
argument:
Page Navigation Functions
goToNextPage()
goToNextPage()
Navigates to the next page in the flow.
This is useful when you want to navigate to the next page in the flow, but don’t want to use the default navigation logic.
goToPrevPage()
goToPrevPage()
Navigates to the previous page in the flow.
This is useful when you want to navigate to the previous page in the flow, but don’t want to use the default navigation logic.
goToPage(pageKeyOrIdOrIndex: string | number)
goToPage(pageKeyOrIdOrIndex: string | number)
Navigates to a page with the specified key, ID, or index - you can choose which type of identifier to pass in.
Data Management Functions
getUserData()
getUserData()
Returns the current User Data from the flow controller.
This is useful when you need to read the current state of User Data, as opposed to the initial userData value that was passed in as the first argument.
setUserData(key: string, value: any)
setUserData(key: string, value: any)
Updates a specific key/value pair in the User Data.
setUserData(updates: Record<string, unknown>)
setUserData(updates: Record<string, unknown>)
Updates multiple fields in the User Data at once.
Accepts an object containing key/value pairs to update - i.e. to merge into the existing User Data.
Note that nested objects will be replaced entirely, not merged.
resetUserData()
resetUserData()
Resets all User Data to its initial state, effectively starting fresh.
Use with caution as this will clear all previously stored User Data.
Component and UI Functions
getComponentElement(key: string)
getComponentElement(key: string)
Returns the DOM element for a component with the specified key.
Useful for direct DOM manipulation, accessing element properties (such as value
for a password input field), or setting up custom event listeners.
openInfoBox(infoBoxPageKey: string)
openInfoBox(infoBoxPageKey: string)
Opens an info box with the specified page key.
The page key must refer to a page which is designed to be shown within an info box.
Returns a Promise that resolves when the info box is opened.
closeInfoBox()
closeInfoBox()
Closes the currently open info box. Returns a Promise that resolves when the info box is closed.
Action and Flow Control
triggerAction(actionId: string)
triggerAction(actionId: string)
Programmatically triggers an action by its ID.
Returns a Promise that resolves when the action is complete.
Useful for chaining actions or conditional action execution.
triggerValidation()
triggerValidation()
Triggers form validation on the flow controller.
Useful when you need to validate form inputs programmatically.
Analytics and Events
trackCustomEvent(customEventName: string, customEventProps: any)
trackCustomEvent(customEventName: string, customEventProps: any)
Tracks a custom analytics event with the given name and properties.
Additional Helpers
helpers
helpers
An object containing various utility helper functions. The exact available helpers depend on the context and implementation.
Trigger Context variables
Please note that old_user_data
and new_user_data
currently only
contain the input keys for the Computed Field, not all of User Data. This may
change in the future.