Step 3. Link Dynamic Picklists
VFW090 – Field Visualizations
The next example demonstrates how dynamic picklists can be linked. A dynamic picklist for Sections can be loaded from the Section table (SECTAB), but the Sections dynamic picklist, must be rebuilt whenever the department changes.
1. Create a new
:iiiVFW21
Departments Dynamic Picklist
2. Add the following immediately after the comment line * populate dynamic picklist, replacing the supplied code:
* Populate dynamic picklist
Select Fields(#deptment #deptdesc) From_File(deptab)
#Picklist.Add( #deptment #deptdesc )
Endselect
Having completed
, you should now be familiar with what this code is doing.3. Compile your new reusable part.
4. Create a new field iiiDepartment by copying field DEPTMENT, copy rules, visualizations and help text. Open the new field in the editor.
5. Select the
tab. Use the to add a In the Find dialog, select the RP, iiiVFW21.a. Select the new
component and adjust the width of the dropdown to display the department description.b. Select the True.
component and use the tab to change its property toc. Select the ShowValue.
component and use the tab o change its property to
6. Save and close the field definition.
7. Create a new
:iiiVFW22
Section Dynamic Picklist
8. Add the following code, immediately after the *Populate the picklist comment line, replacing the default code provided:
Select Fields(#section #secdesc) From_File(sectab) With_Key(#deptment)
#Picklist.Add( #section #secdesc )
Endselect
9. There is a new requirement for the Sections Dynamic Picklist. It needs to monitor changes in the field DEPTMENT.
To do this it needs to also implement
and include a method routine for .10. Extend your code based on the changes highlighted in red below:
Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_OBJT *implements #Prim_dc.iDynamicPicklist #Prim_dc.iMonitorSubject)
Mthroutine Name(Load) Options(*redefine)
#Picklist.RemoveAll
* Populate the picklist
Select Fields(#section #secdesc) From_File(Sectab) With_Key(#Deptment)
#Picklist.Add( #Section #Secdesc )
Endselect
Endroutine
Mthroutine Name(ApplyMonitoredValue) Options(*Redefine)
#Deptment := #MonitorSubject.GetValue
Endroutine
End_Com
Note: The
routine displays the defined in its ancestor.11. Compile the new reusable part.
12. Create a new field iiiSection by copying field SECTION, copy rules, visualizations and help text. Open the new field in the editor.
13. Select the
tab and add a and select iiiVFW22.a. Adjust the width of the
dropdown.b. Make the
the field's visualization.c. Select the ShowValue.
component and use the tab to change the to14. Save and close the field definition.