WAM045 - A Dynamic Selector Dropdown list using a Select Field
1. Create WAM iiiDynamSelector – Dynamic Selector using Select Field by copying WAM iiiEmpUpdate_MK2 including the Active Designs:
2. Change the definition of the SECTDD list to include DEPTMENT:
Def_List Name(#sectdd) Fields(#deptment #section #secdesc) Type(*Working)
3. Remove the USect_DD WebRoutine, which is no longer required.
4. In the Details webroutine, move the code to invoke the BuildDD2 method routine to the position shown, at the end of the When (= M) logic. The moved code is shown in red. This routine will be now be invoked once only, when the Details WebRoutine is initially called from the Begin web page.
WebRoutine Name(Details) Desc('Employee Details')
Web_Map For(*BOTH) Fields(#EMPDATA (#deptdd *json) (#sectdd *json))
Case (#STDRENTRY)
When ('= M')
Fetch Fields(#EMPDATA) From_File(PSLMST) With_Key(#EMPNO) Val_Error(*NEXT)
If_Status Is_Not(*OKAY)
Message Msgtxt('Employee not found')
Transfer Toroutine(Begin)
Endif
Change Field(#EMPNOW) To(#EMPNO)
#com_owner.BuildDD2 I_Dept(#deptment) I_Sect(#section)
5. Change the BuildDD2 method routine to match the following:
The Select now reads all records (no With_key(#deptment) ).
An If / Endif block has been removed
The code shown in red has been added.
Mthroutine Name(BuildDD2)
Define_Map For(*input) Class(#deptment) Name(#i_dept)
Define_Map For(*input) Class(#section) Name(#i_sect)
Clr_List Named(#sectdd)
* Read all Section records
Select Fields(#sectdd) From_File(sectab)
Add_Entry To_List(#sectdd)
Endselect
Loc_Entry In_List(#sectdd) Where((#deptment = #i_dept) And (#section = #i_sect))
Endroutine
The LOC_ENTRY statement sets the values of DEPTMENT and SECTION to the values retrieved for the current employee.
6. Compile your WAM.