1. Copy the iiiAddEmployee web page which you created earlier.
Give the new web page the name iiiAddEmployeeNew.
2. On the Outline tab, use the context menu on field xDepartmentCode, to Delete Component.
3. Drag the new field iiiDepartment to the top right of the left hand column. Select the Layout ribbon and set up the new field as follows:
4. You now need to include the new dropdown field in the Find and Save method routines.
a. In the Find method routine, within the GetEmployee.Completed event routine, assign iiiDepartment the value of xDepartmentCode:
Define_Com Class(#iiixEmployeeDataServer.find) Name(#GetEmployee)
#GetEmployee.executeasync( #xEmployeeIdentification #xEmployee #IO$STS )
#iiiDepartment := #xDepartmentCode
b. In the Save method routine, assign xDepartmentCode the value iiiDepartment, before execute SaveEmployee srvroutine.
c. Also set iiiDepartment to *null after the employee changes have been saved.
Your code should look like the following:
Mthroutine Name(Save) Access(*PRIVATE)
Define_Com Class(#iiixEmployeeDataServer.save) Name(#SaveEmployee)
#xDepartmentCode := #iiiDepartment
#SaveEmployee.executeasync( #xEmployee #io$sts )
If (#IO$STS = OK)
#xEmployee #iiiDepartment := *default
5. Compile the new Add Employee web page.
6. Test the new Add Employee web page. When the web page loads, the Department dropdown should contain an entry for all departments:
Note: There are one or two employee records with a blank department code. If one of these employees are retrieved, the department dropdown will not be set.