Trying to use IF ELSE to choose a VALUELIST...

… based on the contents of a separate dataprovider…

The sample code goes:

//Get all values from a custom or database type value list
//Note:see databaseManager.JSDataSet for full details of dataset
var dataset = application.getValueListItems(‘my_en_types’);

//example to assign to dataprovider
//employee_salary = dataset.getValue(0,0)

Where ‘my_en_types’, I assume, is the name of the custom or database value list.

But what is the (0,0) referencing in getValue?

In servoy a valuelist can have multiple columns, so the syntax is getValue(row,col)
But there is indeed a glitch in that sample, getValue(0,0) should be getValue(1,1) (we have corrected this for Servoy 2.1.1)
To see more samples for functions on a dataset open the databaseManager and move sample code for the function on the JSDataset object.

Thanks Jan!

If the separator for the values lists is the <|> character, does it require a space on either side, separating the valuelist columns?

Also, and I hate to ask such a specific question, is my syntax correct?

(where origin is a dataprovider with a specific value, “Wendy” selected from valuelist, also called Origin, and sub_type_designation is a dataprovider with a specific valuelist that is being set)

if(forms.tab_address_main.origin == “Wendy”)
{
var dataset = application.getValueListItems(‘SubType’);
sub_type_designation = dataset.getValue(1,1)
}
else
{
var dataset = application.getValueListItems(‘SubType’);
sub_type_designation = dataset.getValue(1,2)
}