You can execute your own JavaScript code on the flow from our Code section as shown below.

Available Functions´╗┐

init() is the function that executes when the flow initializes for the first time on the window. It doesn't matter which screen the flow is accessed from and therefore, even if you reload the window on a random screen, it executes.

onRender() is the function that executes every time a flow screen renders. Therefore, we also pass the screenId to it which can be used to perform screen-specific functions. The screenId is the name given to each screen.

Defining Variables

If you need a variable defined per screen, you can define them in the onRender() function.

However, as the init() and onRender() functions are async, we recommend defining global variables outside the functions first.

If the variable's value has been declared inside init() and then needs to be accessed per screen, then accessing them on the screen once, we recommend checking if the value is available before accessing it. The following is a sample code for this scenario:

//Define global variable outside the scope of the functions

var globalX;

window.Client = {
init: function() {
// Do something on initialization
globalX="I am global and I have value";

onRender: function(screenId) {
// Do something when the flow renders
if (globalX) {
alert (globalX);

Did this answer your question?