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. To do this, 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 Employee page.
Note:
You must create all new action chains in JavaScript, which offers significant advantages over JSON. You can still edit existing JSON action chains, however. If you're not clear on the benefits of using JavaScript over JSON, see the next topic.JavaScript and JSON Action Chains
- 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.