Step 5. Use the Switch History to Return to the Original Business Object

In this step you will use the switch history to allow the end-user to return to the Departments business object from where they initiated the switch.

1.   Open the Employees' Details command handler iiiCOM03.

2.   Display the Controls tab and drag a push button under the Save button.

3.   Make the Caption of the button Back.

4.   Make the Name of the button BACK_BTN.

5.   Add a Click event for the button.

6.   In the Click event add this code so that when the users click on the button, they will be switched back to the business object from which they came:

define field(#ff_objnme) TYPE(*CHAR) LENGTH(32) DESC('Object Name')

define field(#ff_cmdnme) TYPE(*CHAR) LENGTH(32) DESC('Command Name')

* Determine the business object name to switch to

#avFrameworkManager.avrestorevalue WithID1(SWITCH_HISTORY) WithID2(#com_owner.Avobjecttype) WithID3(#com_owner.Avcommandtype) WithID4(OBJECT_NAME) ToAValue(#ff_objnme)

* Determine which command within the business object to switch to

#avFrameworkManager.avrestorevalue WithID1(SWITCH_HISTORY) WithID2(#com_owner.Avobjecttype) WithID3(#com_owner.Avcommandtype) WithID4(COMMAND_NAME) ToAValue(#ff_cmdnme)

* Perform the switch

#avframeworkmanager.avSwitch To(BUSINESSOBJECT) NAMED(#ff_objnme) EXECUTE(#ff_cmdnme)  Caller(#com_owner)

 

 Your code should look like this:

VLF00950

 

7.   Now compile the command handler.

 

You are now ready to test the switch history:

8.   In the Framework select a department from the Departments business object.

9.   Select an employee from the Departments' Details command handler.

10.   Display the details of the selected employee by clicking on the Details button.

11.   On the Details command handler of the Employees business object click on the Back button to return to the Departments business object.