replaceAction()
Last updated 28/01/2025
The
When using with
In the previous chapters,
Multiple actions and functions are used to demonstrate replacing actions on a dashboard.
In this tutorial, the following will be performed to demonstrate how
- Add the Customer table - The Customer table is added to use as the data source for the Customers form.
- Add the Customers form - The Customers form is added so records can be saved in the Action Navigation app and we can use the optional recordKeyparameter to select a specific form record.
- Add the Replace Demo dashboard - To demonstrate how the functions replaceAction()andpreviousAction()work together.
- Add the ReplaceProcessAfunction - When on Process A on the Replace Demo dashboard, will replace Process A with Process C.
- Edit the Process A record - To add an action button and attach the ReplaceProcessA()function.
Add the Customer Table
The Customer table is added so we can create a Customers form.
1. Select Data in the menu.2. Select Table Wizard in the sub-menu.
3. Type Customer in the Name field.
4. Click the Add Fields button.
5. Type Name in the Name field.
6. Click the Save button in the Table Wizard app bar.
7. Click the Save button in the Table Upgrade window.
Add the Customers Form
The Customers form is added so we can add some records to demonstrate later in this tutorial how to pass in the optional
2. Select Form Wizard in the sub-menu.
3. Click the lookup icon in the Main Data Source field and select Customer.
4. Click the Save button in the Form Wizard app bar.
Add the Replace Demo Dashboard
The Replace Demo dashboard is added so we can add multiple dashboard areas to demonstrate how the functions
2. Select Dashboards in the sub-menu.
3. Click the Add Item button.
4. Type Replace Demo in the Title field.
5. Type 2 in the Columns field.
6. Click the Actions tab.
7. Click the Add Actions button.
8. Click the Edit button in the Page Position field.
9. Select A1 and click the Save button in the grid picker.
10. Click the lookup icon in the Action field and select ProcessA (Process).
11. Click the Save button in the form app bar.
12. Click the Add Actions button.
13. Click the Edit button in the Page Position field.
14. Select B2 and click the Save button in the grid picker.
15. Click the lookup icon in the Action field and select ProcessB (Process).
16. Click the Save button in the form app bar.
17. Click the Save button in the form app bar above the list.
Add the ReplaceProcessA Function
The
2. Select Functions in the sub-menu.
3. Click the Add Item button.
4. Type ReplaceProcessA in the Function ID field.
5. Click in the Code field to open the Code Editor.
6. Copy and paste the code block below.
function ReplaceProcessA(five, context, result) {
five.replaceAction('ProcessC');
return five.success(result);
}
7. Click the Save button in the Code Editor app bar.
8. Click the Save button in the form app bar.
Edit Process A
The Process A record already saved in the Action Navigation application, needs to be edited to add an action button. The
2. Select Processes in the sub-menu.
3. Select the Process A record in the list.
4. Click the Action Buttons tab.
5. Click the Add Action Buttons button.
6. Type Replace Process A in the Caption field.
7. Click the Events tab.
8. Click the lookup icon in the On Press field and select ReplaceProcessA
9. Click the Save button in the form app bar.
10. Click the Save button in the form app bar above the list.
How This Works in an Application
In the Action Navigate application when you select the Replace Demo menu, you will be on the Replace Demo dashboard. On the dashboard are Process A and Process B.
In Process A's app bar is the Replace Process A button. Click this button.
Once the button is clicked, Process A will be replaced with Process C.