11 Work With JSON Action Chains

Action chains determine what happens when users interact with pages or components in your user interface, for example, when they select a row in a table or click a button on a page. Each action chain defines a sequence of actions (for example, navigating to a page, calling a REST endpoint, assigning data to a variable, and so on) and is started by an event listener when an event occurs.

Say you want users who click an Edit button on a List of Employees page to be taken to a page that lets them change employee details: you'd define an ojAction event for the Edit button, create an event listener that listens for the ojAction event, and select an action chain with a Navigate action to open the Edit Employee page. Now whenever the ojAction event occurs, the event listener triggers the action chain to navigate to the edit page.

Note:

All new action chains are now created using JavaScript, which offers significant advantages over JSON. Existing JSON chains can be edited, but no new JSON chains or tests for JSON chains can be created. For a list of benefits to using JavaScript, see the following subsection.

JavaScript and JSON Action Chains

You can call a JSON action chain from a JavaScript action chain using the Call Action Chain action; however, you can't call a JavaScript action chain from a JSON action chain.

We recommend that you use JavaScript action chains (rather than JSON), as they provide a number of benefits, including:
  • The JavaScript Action Chain visual editor offers a helpful Structure pane.
  • The JavaScript code editor includes an Actions palette, a Structure pane, and a Properties pane to assist with writing code.
  • JavaScript action chains can use local functions to improve modularization and keep related logic together.
  • Using JavaScript offers numerous advantages, including:
    • Easier debugging, since you can use your browser's Developer tools.
    • Easier management of code through Git operations, such as merge.
    • Self-contained action chains, eliminating the need for external module functions to handle complex code.
    • Built-in types with extensive methods and properties for simplifying common tasks.
    • Powerful data manipulation capabilities, including complex transformations, filtering, and mapping.
    • A rich standard library to leverage.
    • A comprehensive range of control flow and transfer statements, like while loops and try-catch statements, for implementing complex logic and error handling.