How do I set a combobox to item 3 (can be anything) of an attached valuelist.
This doesn’t work
var myArray = application.getValueListItems(‘FormsList’)
forms.controls.elements.global_Form_list = myArray[1];
returns an error about locked scope.
I tried setting the field to be editable to no avail…
Ideas ?
TIA
david
2
With this function you do not get an Array back – you get back a dataset type. So:
var dataset = application.getValueListItems('FormsList');
fieldName = dataset.getValue(3,1);
To set a combo box field to the second and third items:
var dataset = application.getValueListItems('FormsList');
fieldName = dataset.getValue(2,1) + '\n' + dataset.getValue(3,1);
iPhoneTest.servoy (6.49 KB)
doing as stated above gives me:
Error
Can’t put in a locked scope, name: global_Form_list, value: Klanten
![Crying or Very sad :cry:]()
david
4
In your code, the left side of this assignment is wrong:
Odysseus:
forms.controls.elements.global_Form_list = myArray[1];
You cannot assign a value to an element. You can only assign a value to properties of elements. That being said, the function:
elements.name_first.replaceSelectedText(myArray[1]);
behaves outside of this rule of thumb.
The left side of an assignment needs to be a variable or a field name:
var x = myArray[1]
fieldNameX = myArray[1]
Which gets us back to this:
fieldName = dataset.getValue(3,1);
for this example.