In this step you will add logic to the Departments command handler to display the details of a selected employee in the Details command handler of the Employees business object.

The switch to the Employees' Details command handler will be executed in a button click event.

1.   Display the Design tab of the Details command handler.

2.   Drag a push button from the Controls tab on to the right hand panel (PANL_1) on the command handler.

3.  Using the Layout ribbon, give the button an Alignment of Top Center. Give it a Top margin of 10.

4.   Make the Caption of the button Details.



5.   Create a Click event for the button.

6.   In the click event add a statement to switch to the Details command handler of the Employees business object.

   #avframeworkmanager.avSwitch To(BUSINESSOBJECT) NAMED(EMPLOYEES) EXECUTE(DETAILS)  Caller(#com_owner) ClearInstanceList(TRUE)

 
7.   Next add the following event routine which will tell the Employees business object which instance should be displayed based on the value of the employee in the grid:

   Evtroutine Handling(#avFrameworkManager.avAddSwitchInstances) Options(*NOCLEARERRORS *NOCLEARMESSAGES) Caller(#Caller)
   * Make sure the caller is this component
If_Ref Com(#Caller) Is_Not(*Equal_to #Com_Owner)
Return
Endif
Invoke Method(#avFrameworkManager.avAddSwitchInstance) Businessobjecttype(EMPLOYEES) Visualid1(#xEmployeeIdentification) Visualid2(#xEmployeeSurname.AsNativeString)
Akey1(#xEmployeeIdentification)
Endroutine

  
Your code should now look like this:


 
8.   Compile the command handler.

9.   Test the switching: when you select an employee and click on the Details button on the Departments' Details Command Handler, the Employees business object is displayed with the selected employee details.