In this step, you will add a Save button for employee details and create an UpdateEmployee method routine. At this stage, employee notes will not be updated.
1. Add a push button to the top of row 4, column 1.
2. Change the button's Alignment to Top Right.
a. Give it a margin Right of 20 and a margin Top of 10.
b. Change its Caption to Save.
c. Change its Name to Save_Employee.
d. Give it an Image of xImageSave16.
e. Create a Click event for the Save button.
3. Create a SaveEmployee method routine, based on the following:
Map for input of class xEmployeeIdentification, Name EmployeeID
Define a component iiixEmployeeDataServer / Save srvroutine, with name UpdateEmployee.
Assign xEmployeeIdentification to value EmployeeID
Execute UpdateEmployee asynchronously, exchanging Group_By xEmployee and field IO$STS.
Within a Completed event routine for UpdateEmployee:
If IO$STS is equal OK
Assign fields in Group_By xEmployee the value null
Set Label_Details.Caption to blank.
End Routine
Your code should look like the following:
Mthroutine Name(SaveEmployee) Define_Map For(*INPUT) Class(#xEmployeeIdentification) Name(#EmployeeID) Define_Com Class(#iiixEmployeeDataServer.save) Name(#UpdateEmployee) #xEmployeeIdentification := #EmployeeID #UpdateEmployee.ExecuteAsync( #xEmployee #io$sts ) Evtroutine Handling(#UpdateEmployee.Completed) If (#io$sts = OK) #xEmployee := *null #Label_Details.Caption := "" Clr_List Named(#NotesList) Endif Endroutine Endroutine
4. Complete the Save_Employee button Click event by adding code to invoke the SaveEmployee method passing xEmployeeIndentification.
Your code should look like the following:
Evtroutine Handling(#Save_Employee.Click) #COM_SELF.SaveEmployee( #xEmployeeIdentification ) Endroutine
5. Compile and test the web page.
- Change an employee, for example, change Given Name and click the Save button. If the update is successful, the employee fields and employee notes list will be cleared.
- Retrieve the same employee by selecting it in the EmployeeList dropdown and show that your changes were saved.
- Clear the Given Name field and click Save. Due to validation rules defined in the Repository, the update will fail and employee fields will not be cleared. Note that error messages are not currently being displayed.