Skip to main content

restoreAction()

Last updated 10/02/2025

The

function will restore a selected or replaced action to it's original state. By default,

restoreAction()
will restore a selected action. When setting the
revertSelect
parameter to
false
, you can restore replaced actions on a dashboard.

In the previous chapters,

,
previousAction()
, and
replaceAction()
, three processes and a dashboard were created, we are going to use these actions to demonstrate how

restoreAction()
works.


info
The Action Navigation application is created to demonstrate the
restoreAction()
function, the creation of this application is documented in the Introduction chapter so you can perform the tutorial. The
restoreAction()
tutorial follows on from the
selectAction()
,
previousAction()
, and
replaceAction()
tutorials.

Multiple actions and functions are used to demonstrate restoring an action to its original state.

In this tutorial, the following will be performed to demonstrate how

restoreAction()
and
selectAction()
work together:

  • Add the
    RestoreOriginal()
    function - To demonstrate using
    selectAction()
    twice and then
    restoreAction()
    to return to the original action.
  • Edit the Process C record - To add a button screen field that will restore Process A.

Process A is already saved in the Action Navigation application and it has a To Process B button screen field that uses the

selectAction()
function, which navigates you to Process B.


Process A
Figure 1 - Process A

Process B is already saved too and it has a To Process C button screen field that uses the

selectAction()
function, which navigates you to Process C. We will be using these actions to demonstrate
restoreAction()


Process B
Figure 2 - Process B

Add the RestoreOriginal Function

The

RestoreOriginal()
function will use Five's
restoreAction()
function on the
Five
object to restore the original action. No parameters need to be passed into the
restoreAction()
function, by default, Five sets
true
which will restore the original action.

1. Select Logic in the menu.

2. Select Functions in the sub-menu.


Functions menu item
Figure 3 - Functions menu item

3. Click the Add Item button.

4. Type RestoreOriginal in the Function ID field.

5. Click in the Code Field to open the Code Editor.


Add the RestoreOriginal function
Figure 4 - Add the RestoreOriginal function

6. Copy and paste the code block below.

note
The code block needs to be pasted over the template that Five creates in the editor.

JavaScript
Restores the original action
function RestoreOriginal(five, context, result) {
five.restoreAction();
return five.success(result);
}

7. Click the Save button in the Code Editor app bar.


Save button
Figure 5 - Save button

8. Click the Save button in the form app bar.


Save button
Figure 6 - Save button

Edit Process C

The Process C record that was added in the previous chapters needs to be edited to add a button, this button will have an On Click event that will reference the

RestoreOriginal()
function. When the button is clicked, the function will execute and restore the original action.

1. Select Tasks in the menu.

2. Select Processes in the sub-menu.


Processes menu item
Figure 7 - Processes menu item

3. Select the Process C record in the list.

4. Click the Screen Fields tab.


Screen Fields tab
Figure 8 - Screen Fields tab

5. Click the Add Screen Fields button.


Add Screen Fields button
Figure 9 - Add Screen Fields button

6. Type Restore Original in the Caption field.

7. Click the lookup icon in the Display Type field and select _Button.


Add Restore Original field
Figure 10 - Add Restore Original field

8. Click the Events tab.


Events tab
Figure 11 - Events tab

9. Click the lookup icon in the On Click field and select RestoreOriginal.


On Click field
Figure 12 - On Click field

10. Click the Save button in the form app bar.


Save button
Figure 13 - Save button

11. Click the Save button in the form app bar above the list.


Save button
Figure 14 - Save button

How This Works in an Application

Deploy/run your application, you will be positioned on Process A. Click the To Process B button.


To Process B button
Figure 15 - To Process B button

The event will execute the

ToProcessB()
function and selects Process B. This is because
ProcessB
is passed into
selectAction()
. Click the To Process C button.


To Process C button
Figure 16 - To Process C button

The event will execute the

ToProcessC()
function and selects Process C. This is because
ProcessC
is passed into
selectAction()
. Click the Restore Original button.


Restore Original button
Figure 17 - Restore Original button

The event will execute the

RestoreOriginal()
function and restores Process A, as this is the original action.


Process A
Figure 18 - Process A


tip
You can use
previousAction()
to return to a specified previously selected action!

RestoreAction in a Dashboard

When on a dashboard the

revertSelect
parameter in the
restoreAction()
function can be set to
false
. When the
revertSelect
parameter is
false
, this will restore the original action on a dashboard.

Multiple actions and functions are used to demonstrate restoring an action on a dashboard to its original state.

In this tutorial, the following will be performed to demonstrate how

restoreAction()
and
replaceAction()
work together:

  • Add the
    ReplaceProcessC()
    function - When on Process Process C on the Replace Demo dashboard, will replace Process C with Process B.
  • Add the
    RestoreOriginalDashboard()
    function - To demonstrate using
    replaceAction()
    twice and then
    restoreAction()
    to return to the original action.
  • Edit the Process C record - To add an action button and attach the
    ReplaceProcessC()
    function.
  • Edit the Process B record - To add an action button and attach the
    RestoreOriginalDashboard()
    function.

The Replace Demo dashboard that was added in the previous chapters holds the Process A and Process B actions. Process A has an action button called Replace Process A, when the button is clicked it will replace Process A with Process C.


Replace Demo dashboard
Figure 19 - Replace Demo dashboard

Add the ReplaceProcessC Function

The

ReplaceProcessC
function needs to be added so we can add an action button on Process C that will replace Process C with Process B.

The

ReplaceProcessC()
function will use Five's
replaceAction()
function on the
Five
object and pass in the action ID
ProcessB
. This will replace Process C with Process B.

1. Select Logic in the menu.

2. Select Functions in the sub-menu.


Functions menu item
Figure 20 - Functions menu item

3. Click the Add Item button.

4. Type ReplaceProcessC in the Function ID field.

5. Click in the Code field to open the Code Editor.


Add ReplaceProcessC function
Figure 21 - Add ReplaceProcessC function

6. Copy and paste the code block below.

note
The code block needs to be pasted over the template that Five creates in the editor.

JavaScript
Replaces action ID ProcessC with action ID ProcessB
function ReplaceProcessC(five, context, result) {
five.replaceAction('ProcessB');
return five.success(result);
}

7. Click the Save button in the Code Editor app bar.


Save button
Figure 22 - Save button

8. Click the Save button in the form app bar.


Save button
Figure 23 - Save button

Add the RestoreOriginalDashboard Function

The

RestoreOriginalDashboard()
function will use Five's
restoreAction()
function on the
Five
object to restore the original action. The
revertSelect
parameter needs to be set to
false
in the
restoreAction()
function to restore the original action on the Replace Demo dashboard.

1. Click the Add Item button.

2. Type RestoreOriginalDashboard in the Function ID field.

3. Click in the Code field to open the Code Editor.


Add RestoreOriginalDashboard function
Figure 24 - Add RestoreOriginalDashboard function

4. Copy and paste the code block below.

note
The code block needs to be pasted over the template that Five creates in the editor.

JavaScript
Restores original action on a dashboard
function RestoreOriginalDashboard(five, context, result) {
five.restoreAction(false);
return five.success(result);
}

5. Click the Save button in the Code Editor app bar.


Save button
Figure 25 - Save button

6. Click the Save button in the form app bar.


Save button
Figure 26 - Save button

Edit Process C

The Process C record that was added in the previous chapters, needs to be edited to add an action button. The button will have an On Press event and when clicked, the

ReplaceProcessC()
function will execute and replace Process C with Process B.

1. Select Tasks in the menu.

2. Select Processes in the sub-menu.


Processes menu item
Figure 27 - Processes menu item

3. Select the Process C record in the list.

4. Click the Action Buttons tab.


Action Buttons tab
Figure 28 - Action Buttons tab

5. Click the Add Action Buttons button.


Add Action Buttons button
Figure 29 - Add Action Buttons button

6. Type Replace Process C in the Caption field.

7. Click the Events tab.


Events tab
Figure 30 - Events tab

8. Click the lookup icon in the On Press field and select ReplaceProcessC.


On Press field
Figure 31 - On Press field

9. Click the Save button in the form app bar.


Save button
Figure 32 - Save button

10. Click the Save button in the form app bar above the list.


Save button
Figure 33 - Save button

Edit Process B

The Process B record that was added in the previous chapters, needs to be edited to add an action button. The button will have an On Press event and when clicked, the

RestoreOriginalDashboard()
function will execute and restore the original action on the dashboard.

1. Select the Process B record in the list.

2. Click the Action Buttons tab.


Action Buttons tab
Figure 34 - Action Buttons tab

3. Click the Add Action Buttons button.


Add Action Buttons button
Figure 35 - Add Action Buttons button

4. Type Restore Original in the Caption field.

5. Click the Events tab.


Events tab
Figure 36 - Events tab

6. Click the lookup icon in the On Press field and select RestoreOriginalDashboard.


On Press field
Figure 37 - On Press field

7. Click the Save button in the form app bar.


Save button
Figure 38 - Save button

8. Click the Save button in the form app bar above the list.


Save button
Figure 39 - Save button

How This Works in an Application

Deploy/run your application and 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.


Replace Process A button
Figure 40 - Replace Process A button

The event will execute the

ReplaceProcessA()
function and replaces Process A with Process C in the dedicated dashboard area. This is because
ProcessC
is passed into
replaceAction()
In Process C's app bar is the Replace Process C button. Click this button.


Replace Process C button
Figure 41 - Replace Process C button

The event will execute the

ReplaceProcessC()
function and replaces Process C with Process B in the dedicated dashboard area. This is because
ProcessB
is passed into
replaceAction()
In Process B's app bar is the Restore Original button. Click this button.


Restore Original button
Figure 42 - Restore Original button

The event will execute the

RestoreOriginalDashboard()
function and returns to Process A as this was our original action. This is because
false
is passed into
restoreAction()
.


Process A
Figure 43 - Process A