KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Programmatically assign placeholder value to pop-up menu/drop-down list
PRODUCT: 4D | VERSION: 19 | PLATFORM: Mac & Win
Published On: August 5, 2021

Placeholders are used in pop-up/drop-down lists to inform the user of available actions (e.g. “Select an option”). There are a couple ways to programmatically assign a placeholder value to a pop-up/drop-down object, depending on its data source expression type. If the object is based on an array, then (before the object is loaded) we can assign index 0 of the array to the desired placeholder value, and then set the array to that index. For example, let’s say that the array variable for the object is myArray. To assign a placeholder that states “Select an option…”, we can do this:

myArray{0}:="Select an option…”
myArray:=0

If the pop-up/drop-down is based on an object, then we can set the index property of the object expression to -1, and assign its currentValue property to the placeholder value. For example, let’s say that the object expression is Form.myObject. To assign a placeholder, we can do this:

Form.myObject.index:=-1
Form.myObject.currentValue:="Select an option…”

Either way, the pop-up/drop-down list will be populated with a placeholder.