Step 3. Add a Routine to Listen for the EMPLOYEE_CHANGED Event
In this step you will change the Employees filter to listen for the EMPLOYEE_CHANGED event.
1. Locate and open the Employees filter iiiCOM04.
2. Display the Source tab.
3. Register the EMPLOYEE_CHANGED event in the UHandleEvent webroutine:
Invoke Method(#avFrameworkManager.avRegisterEvent) Named(EMPLOYEE_CHANGED) Signalaswamevent(2)
The UHandleEvent will now look like this:
4. Scroll to the end of the WAM source and add an event routine to listen for the EMPLOYEE_CHANGED event signal:
Evtroutine Handling(#avFrameworkManager.uWAMEvent_2) Withid(#eventid) WithAinfo1(#Ainfo1) Options(*noclearmessages *noclearerrors)
Endroutine
5. In the event routine first add code to check the event id:
If '#EventId.Value = EMPLOYEE_CHANGED'
Endif
6. Then save the current key values from overwrites done by the select loop:
Inz_List #Save_Keys 1
7. Assign the value passed by the signaled event to the EMPNO field:
#EmpNo := #AInfo1
8. Start updating the instance list:
Invoke Method(#avListManager.BeginListUpdate)
9. Fetch the details of the employee that has been updated:
FETCH FIELDS(#SURNAME #GIVENAME #EMPNO) FROM_FILE(PSLMST) WITH_KEY(#EMPNO)
10. Update the entry in the instance list:
Use Builtin(BCONCAT) With_Args(#SURNAME #GIVENAME) To_Get(#FULLNAME)
Invoke #avListManager.AddtoList Visualid1(#EMPNO) Visualid2(#FULLNAME) AKey1(#EMPNO)
11. Complete the instance list update:
Invoke Method(#avListManager.EndListUpdate)
12. Lastly restore the saved key values:
Get_Entry 1 #Save_Keys
Your finished code will look like this:
13. Compile the filter and check it in.