Step 7. Retrieve Employee Details

This step will add a new srvroutine to the iiixEmployeeDataServer server module, which returns details for a single employee and a list of the employee's notes. This will enable the required employee data to be retrieved with one trip to the server.

In the web page, you will then create a GetEmployee method, which is invoked from the EmployeeList.ItemGotSelection event.

1.  Open the server module iiixEmployeeDataServer in the editor.

2.  Define working list xEmployeeNotes, for fields xEmployeeNoteGUID, xEmployeeNoteCreateUpdate and xEmployeeNote, with Entrys(*max).

Def_List Name(#xEmployeeNotes) Fields(#xEmployeeNoteGUID #xEmployeeNoteCreateUpdate #xEmployeeNote) Type(*Working) Entrys(*MAX)

3.  Copy the srvroutine Find to create srvroutine FindDetails.

4.  Extend FindDetails as follows:

Add an output map for the list xEmployeeNotes

Add a Val_error(*next) parameter to the FETCH statement

If status is OK

Select list xEmployeeNotes from logical xEmployeeNotesByEmployee with key xEmployeeIdentification

Add all entries to list xEmployeeNotes

End select

     Your code should look like the following:

Srvroutine Name(FindDetails)

Field_Map For(*Input) Field(#xEmployeeIdentification)

Group_Map For(*Output) Group(#xEmployee)

List_Map For(*OUTPUT) List(#xEmployeeNotes)

Field_Map For(*Output) Field(#IO$STS) Parameter_Name(Status)


* Return all data for the keys provided

Fetch Fields(#xEmployee) From_File(xEmployee) With_Key(#xEmployeeIdentification) Val_Error(*NEXT) 

If_Status Is(*OKAY)

Clr_List Named(#xEmployeeNotes)

Select Fields(#xEmployeeNotes) From_File(xEmployeeNotesByEmployee) With_Key(#xEmployeeIdentification)

Add_Entry To_List(#xEmployeeNotes)




5.  Copy the working list definition xEmployeeNotes to the Windows clipboard.

6.  Compile the server module.

7.  Switch to the iiiUpdateFromAList web page in the editor.

8.  Paste the list definition xEmployeeNotes to the web page.

9.  Create a method routine, GetEmployee to perform the following:

Map for input of class STD_CODEL, name EmployeeID

Define a component for iiixEmployeeDataServer / FindDetails, name GetDetails

Assign xEmployee to null

Clear list NotesList

Execute GetDetails asynchronously exchanging EmployeeID, xEmployee, xEmployeeNotes and IO$STS

Within an event routine for GetDetails.Completed

Select list xEmployeeNotes

   Add each entry to NotesList

End Select

End routine

     Your code should look like the following:

Mthroutine Name(GetEmployee)

Define_Map For(*INPUT) Class(#std_codel) Name(#EmployeeID)

Define_Com Class(#iiixEmployeeDataServer.finddetails) Name(#GetDetails)

#xEmployee := *null

Clr_List Named(#NotesList)

#GetDetails.ExecuteAsync( #EmployeeID #xEmployee #xEmployeeNotes #IO$STS )

Evtroutine Handling(#GetDetails.Completed)

Selectlist Named(#xEmployeeNotes)

Add_Entry To_List(#NotesList)




10. Add code to the EmployeeList.ItemGotSelection event, to invoke GetEmployee, and set up employee details on Label_Details:

Evtroutine Handling(#EmployeeList.ItemGotSelection)

* STD_CODEL contains Employee ID

#com_self.GetEmployee( #std_codel )

#Label_Details := '  Employee: ' + #STD_CODEL + ' ' + #iiiFullName


11. Compile the web page.

12. Test the web page. Perform any search. When the first entry in EmployeeList gets focus, the ItemGotSelection should be triggered, retrieving employee details and list of notes.

     Selecting a different employee from the dropdown EmployeeList, should clear and then populate details and the list of notes.