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.

function result(userData, helperFunctions, triggerContext) {
  ...
}

Available arguments in Custom Code functions

Custom Code blocks provide various bits of context through arguments in the root functions. They are, in order:

#ArgumentDescription
1userDataThe current User Data
2helperFunctionsAn object containing various helper functions (see full list below)
3triggerContextAn 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:

Data Management Functions

Component and UI Functions

Action and Flow Control

Analytics and Events

Additional Helpers

Trigger Context variables

type TriggerContext = {
  inputs_causing_recompute: string[]; // List of keys of inputs that caused the recompute
  old_input_values: string[]; // List of old values of those inputs (last time this Computed Field was computed)
  new_input_values: string[]; // List of current values of those inputs
  old_user_data: Record<string, unknown>; // Snapshot of User Data from when this Computed Field was last computed
  new_user_data: Record<string, unknown>; // Current value of User Data (identical to the first userData argument)
};

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.