When using 4D as a Web server in contextual mode, you cannot use choice lists to help users enter correct values and limit the entries to a specific set of values. There can be an easy workaround to that, you can use a pop-up menu to perform the same task.
The example below provides very simple code that populates a pop-up menu based on data extracted from a One table. The code manages the following:
- It populates the menu with data extracted from a string array.
- It displays the existing field value in the pop-up when a record is being edited.
- It displays no field value in the pop-up when a record is being created.
- It saves the value selected by the user when the record is validated
This code should be placed in the form method of the form used to publish the data.
Cut and Paste the following code example into your own 4D project
: (Form event=On Load )
`Method that creates the array used to populate the pop-up menu
`Copying the array into the pop-up array
If ([Table 1]Name#"")
`setting the pop-up to existing value
ItemNumber:=Find in array(Pop1;[Table 1]Name)
: (Form event=On Validate )
`Saving the selected value