Step 6. Retrieve Employee Details

In this step, you will add logic to fetch employee details when an employee is selected in the EmployeeList and read all employee notes into list NotesList.

When an entry is selected in NotesList an entry will be added to multiline edit box EmployeeNote.

1.  At the top of your code, following the Define_Com statements, define a Group_By for the employee fields to be retrieved:

Group_By Name(#EmployeeDetails) Fields(#xEmployeeIdentification #xEmployeeSurname #xEmployeeGivenNames #xEmployeeGender #xEmployeeStreet #xEmployeeCity #xEmployeeState #xEmployeePostalCode #xEmployeeDateofBirth #xEmployeeTitle)

     Hint: Use AutoComplete of F4 Command Assistant to complete the Fields() parameter.

2.  Add code to the EmployeeList.ItemGotSelection event routine to perform the following:

Assign xEmployeeIdentification to #STD_DESCS

Fetch group_By Employeedetails from filetablexEmployee with key xEmployeeIdentification

Clear List NotesList

Read all fields in NotesList from index xEmployeeNotesByEmployee with key xEmployeeIdentification

Add each entry to NotesList

End Select

     Your code should look like the following:

Evtroutine Handling(#EmployeeList.ItemGotSelection) Options(*NOCLEARMESSAGES *NOCLEARERRORS)

#xEmployeeIdentification := #STD_DESCS

Fetch Fields(#EmployeeDetails) From_File(xEmployee) With_Key(#xEmployeeIdentification)

Clr_List Named(#NotesList)

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

Add_Entry To_List(#NotesList)



3.  Add code to the NotesList.ItemGotSelection event routine to clear list EmployeeNotes, fetch field xEmployeeNote and add an entry to multiline edit box EmployeeNotes.

Evtroutine Handling(#NotesList.ItemGotSelection) Options(*NOCLEARMESSAGES *NOCLEARERRORS)

Clr_List Named(#EmployeeNotes)

Fetch Fields(#xEmployeeNote) From_File(xEmployeeNotes) With_Key(#xEmployeeNoteGUID)

Add_Entry To_List(#EmployeeNotes)


     Note: xEmployeeNoteGUID is a hidden column in list NotesList.

4.  Compile and test your form. You should now be able to search for employees by surname or date of birth and select an employee to display details and a list of employee notes. Then select an employee note which is displayed in the multiline edit box.