By default, a picklist field of type "Lookup", will display all the values present in the lookup field. The deluge ui.add / ui.append task is used in on user input field action script and on load form action script, to add an item to a picklist / radio button / checkbox / multiselect lookup field. For example, in the SubmitFeedback form given below, each issue submitted is assigned to a specific team member belonging to a specific module. When a Module is selected from the Module Name picklist, only those team members belonging to the selected module will be listed in the Assign To picklist. This is achieved using the <picklist fieldname>:ui.add(value) Deluge syntax.
Alternatively, you can also specify the Deluge criteria in the Set Criteria option of the lookup field, to create dynamic picklist.
Use the following syntax to add items to a picklist within a Normal form :
Let us take the example of Dynamic Picklist application. The Countries form stores the name of the Countries. States form stores the name of the states for the respective Countries. The Registration form consists of fields to store user information. The goal is to populate picklist entries for States field dynamically, based on the selected country. To add the picklist dynamically, you can either set a filter as shown here, or add the following script in the On User Input action of Countries field in Registration Form.
statelist = States [Country_Name == input.Country] sort by State_Name;
Use the following syntax to add items to a picklist within a subform:
row.<picklist field>:UI.append(<LIST VARIABLE>/<STRING VARIABLE>);
Below is an example code that should be specified in the onUserInput action of subform picklist field.
list = Product [Category == row.Category] sort by Product_Code ;
The UI.append task does not implicitly clear the old items and hence you need to explicitly invoke the clear task. If Items is a lookup or dropdown field and do not contain the value passed to the append task then the append operation will fail.
The sample application "Order Management" illustrates the subform feature.