When using the Modifier to add a list field (drop down list, button drop down list, listbox, multi-select list box) to a window as a local field, the only option available to populate the list was to add static values. This is because there is no functionality available in VBA to add items to a Dexterity list field.
This example shows a method which calls Dexterity sanScript from VBA to get Dexterity to add items to the list field for us. This means that the list field can be dynamically populated based on business rules or data in a table.
Normally, when you call Dexterity sanScript using the Continuum Integration Library, the script is executed in the context of the original form (as it appears in the application dictionary). This means that even though you can get the code to run, it would not be able to see the new local field which only exists in the modified form (as it appears in the custom forms dictionary).
The trick here is to specify that the code should run in the context of modified form. To change the dictionary context and or change to use the modified form, you can use the commands below.
To change the Dictionary context, use the following command to specific the product ID.
CompilerApp.CurrentProductID = 0 ' Optional line to change Dictionary Context
To change the Dictionary context to use the modified version of a window, use the following command.
CompilerApp.CurrentProduct = CompilerApp.CurrentProduct & "!Modified"
This example changes the User Setup window to add a drop down list at the bottom of the window. This list is dynamically populated with the names of the companies a user has access to when a user is displayed on the window. The pass through sanScript code loops through a range on the SY_User_Company_Access_REL (SY60100) table to read the Company ID and then looks up the SY_Company_MSTR (SY01500) table to get the Company Name.
NOTE: This customisation uses a method of executing Dexterity sanScript code from VBA which is unsupported by Microsoft.
Example code for v8.0, v9.0 & v10.0 is attached at the bottom of the article.
Please see the "Installation Instructions.txt" file in each version's archive for more information.