Skip to main content

previousAction()

Last updated 22/01/2025

The

function returns to the previously selected or replaced action. It will restore selected actions by default, but by setting the

revertSelect
parameter to
false
you can restore replaced actions as well. Optionally, you can pass in a number of actions you want to go back, in the case of more than one action being selected or replaced.

In the previous chapter,

, two processes were created, we are going to build on from that and add another process called Process C to demonstrate the

previousAction()
function. Two buttons will be added to Process C. One button will return to the previously selected action, while the second button will return back to the number of actions specified in the
previousAction()
function.

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

Multiple actions and functions are used to demonstrate returning back multiple actions. All the functions will be added first.

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

selectAction()
and
previousAction()
work together:

  • Add the
    ToProcessA()
    function - When on Process B, will select Process A using
    selectAction()
    .
  • Add the
    ToProcessC()
    function - When on Process B, will select Process C using
    selectAction()
    .
  • Add the
    Previous1()
    function - When on Process C, will return you to Process B using
    previousAction()
    .
  • Add the
    Previous2()
    function - When on Process C, will return you to Process A using
    previousAction()
    and passing in the optional number parameter.
  • Edit the Process B record - To add the screen fields Back to Process A and To Process C, these fields will have a _Button display type and respectively will have the
    ToProcessA()
    and
    ToProcessC()
    functions attached.
  • Add the Process C record - With the screen fields Back One Action and Back Two Actions, these fields with have a _Button display type and respectively have the
    Previous1()
    and
    Previous2()
    functions attached.

Add the ToProcessA Function

The

ToProcessA()
function will navigate you to Process A from Process B using
selectAction()
and passing in the ProcessA action ID.

1. Select Logic in the menu.

2. Select Functions in the sub-menu.


Functions menu item
Figure 1 - Functions menu item

3. Click the Add Item button.

4. Type ToProcessA in the Function ID field.

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


Add ToProcessA function
Figure 2 - Add ToProcessA function

6. Copy and paste the code block below into the editor.

note
The code block needs to be pasted over the boiler template that Five has created by default in the editor.

info
Passing in an action ID to
selectAction()
will navigate you to the action.

JavaScript
Selects ProcessA
function ToProcessA(five, context, result) {
five.selectAction('ProcessA');
return five.success(result);
}

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


Save button
Figure 3 - Save button

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


Save button
Figure 4 - Save button

Add the ToProcessC Function

The

ToProcessC()
function will navigate you to Process C from Process B using
selectAction()
and passing in the ProcessC action ID.

1. Click the Add Item button.

2. Type ToProcessC in the Caption field.

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


Add ToProcessC function
Figure 5 - Add ToProcessC function

4. Copy and paste the code block into the editor.

note
The code block needs to be pasted over the boiler template that Five has created by default in the editor.

JavaScript
Selects ProcessC
function ToProcessC(five, context, result) {
five.selectAction('ProcessC');
return five.success(result);
}

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


Save button
Figure 6 - Save button

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


Save button
Figure 7 - Save button

Add the Previous1 Function

The

Previous1()
function will use Five's inbuilt
previousAction()
function on the
Five
object to return to the previously selected action.

1. Click the Add Item button

2. Type Previous1 in the Function ID field.

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


Add Previous1 function
Figure 8 - Add Previous1 function

4. Copy and paste the code block below.

note
The code block needs to be pasted over the boiler template that Five has created by default in the editor.

info
No parameters need to be passed into
previousAction()
when returning to the previous selected action, by default Five sets
true
and
1
. This will take you back to the previously selected action.

JavaScript
Returns to the previous selected record
function Previous1(five, context, result) {
five.previousAction();
return five.success(result);
}

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


Save button
Figure 9 - Save button

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


Save button
Figure 10 - Save button

Add the Previous2 Function

The

Previous2()
function will use Five's inbuilt
previousAction()
function on the
Five
object and the optional
number
parameter to return back to the number of previous selected actions passed into the function.

1. Click the Add Item button.

2. Type Previous2 in the Function ID field.

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


Add Previous2 function
Figure 11 - Add Previous2 function

4. Copy and paste the code block below into the editor.

note
The code block needs to be pasted over the boiler template that Five has created by default in the editor.

info
true
needs to be passed into
previousAction()
as the first parameter and the number of actions you wish to return to needs to be supplied as the second parameter.

JavaScript
Returns back 2 previous selected actions
function Previous2(five, context, result) {
five.previousAction(true, 2);
return five.success(result);
}

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


Save button
Figure 12 - Save button

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


Save button
Figure 13 - Save button

Edit Process B

The Process B record that was added in the previous chapter,

, needs to be edited to add the buttons that will navigate you to Process A and Process C.

1. Select Tasks in the menu.

2. Select Processes in the sub-menu.


Processes menu item
Figure 14 - Processes menu item

3. Select the Process B record in the list.

4. Click the Screen Fields tab.


Screen Fields tab
Figure 15 - Screen Fields tab

5. Click the Add Screen Fields button.


Add Screen Fields button
Figure 16 - Add Screen Fields button

6. Type Back to Process A in the Caption field.

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


Add Back to Process A screen field
Figure 17 - Add Back to Process A screen field

8. Click the Events tab.


Events tab
Figure 18 - Events tab

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


On Click field
Figure 19 - On Click field

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


Save button
Figure 20 - Save button

11. Click the Add Screen fields button.


Add Screen Fields button
Figure 21 - Add Screen Fields button

12. Type To Process C in the Caption field.

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


Add To Process C screen field
Figure 22 - Add To Process C screen field

14. Click the Events tab.


Events tab
Figure 23 - Events tab

15. Click the lookup icon in the On Click field and select ToProcessC.


On Click field
Figure 24 - On Click field

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


Save button
Figure 25 - Save button

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


Save button
Figure 26 - Save button

Create Process C

Process C will have two screen fields. The Back One Action field will have the

Previous1()
function attached and this will return you back to the previous selected action. The Back Two Actions field will have the
Previous2()
function attached and this will return you back two previous selected actions.

1. Click the Add Item button.

2. Type Process C in the Title field.

Add Process C
Figure 27 - Add Process C

3. Click the Screen Fields tab.


Screen Fields tab
Figure 28 - Screen Fields tab

4. Click the Add Screen fields button.


Add Screen Fields button
Figure 29 - Add Screen Fields button

5. Type This is Process C in the Caption field.

6. Click the lookup icon in the Display Type field and select _Label.


Add This is Process C screen field
Figure 30 - Add This is Process C screen field

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


Save button
Figure 31 - Save button

8. Click the Add Screen Fields button.


Add Screen Fields button
Figure 32 - Add Screen Fields button

9. Type Back One Action in the Caption field.

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


Add Back One Action screen field
Figure 33 - Add Back One Action screen field

11. Click the events tab.


Events tab
Figure 34 - Events tab

12. Click the lookup icon in the On Click field and select Previous1.


On Click field
Figure 35 - On Click field

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


Save button
Figure 36 - Save button

14. Click the Add Screen Fields button.


Add Screen Fields button
Figure 37 - Add Screen Fields button

15. Type Back Two Actions in the Caption field.

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


Add Back Two Actions screen field
Figure 38 - Add Back Two Actions screen field

17. Click the Events tab.


Events tab
Figure 39 - Events tab

18. Click the lookup icon in the On Click field and select Previous2.


On Click field
Figure 40 - On Click field

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


Save button
Figure 41 - Save button

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


Save button
Figure 42 - Save button

How This Works in an Application

Lets see how all this works in the Action Navigation application. To begin with you are on Process A and if you click the To Process B button, you are navigated to Process B, this is because the ProcessB action ID is passed into

selectAction()
in the
ToProcessB()
function.


Process A
Figure 43 - Process A

Once you are navigated to Process B, there are two buttons. If you click the Back to Process A button, you will be navigated to Process A, this is because the ProcessA action ID is passed into

selectAction()
in the
ToProcessA()
function.


Process B
Figure 44 - Process B

Now you are back on Process A, click the To Process B button again to return to Process B.


Process A
Figure 45 -Process A

This will once again take you to Process B. This time click the To Process C button, you will be navigated to Process C, this is because the ProcessC action ID is passed into

selectAction()
in the
ToProcessC()
function.


Process B
Figure 46 - Process B

On Process C, there are two buttons, Back One Action and Back Two Actions. Clicking the Back One Action button will navigate you back to Process B. This is because in

previousAction()
in the
Previous1()
function no parameters were passed in, so it is defaulted to
true
and
1
to take you back to the previous selected action, which for us is Process B.


Process C
Figure 47 - Process C

Now you are back on Process B, click the To Process C button again to return to Process C.


Process B
Figure 48 - Process B

This time click the Back Two Actions button, this will navigate you back to Process A. This is because

true
and
2
were passed into
previousAction()
in the
Previous2()
function, so this will navigate you back two previous selected actions, which for us is Process A.


Process C
Figure 49 - Process C

This all happens without leaving the Process A menu item.


Process A
Figure 50 - Process A