Getting a value from a value list

If I know the value of the return in dataprovider for a valuelist, can I get its corresponding show in list value?

I know I can use application.getValueListItems to get a list of all of the items in a valuelist but I can’t see the return in dataprovider value in its dataset.

Here is the code I wrote thats not working:

var myList = arguments[0]
var myID = arguments[1]
var dataset = application.getValueListItems(myList);
for(var i = 1 ;i <= dataset.getMaxRowIndex() ;i++ )
{
	dataset.rowIndex = i;
	if (myID == dataset[0]) {
		return dataset[1];
	}
}

Is there a way to do this?

add before the “if” a line like:
application.output("dataset[0] “+dataset[0]+” dataset[1] "+dataset[1]);
and check the output debug window for the returned data.

Here is the output that I get:

dataset[0] dataset[1] Client 1
dataset[0] dataset[1] Client 2
dataset[0] dataset[1] Client 3
dataset[0] dataset[1] Client 4
dataset[0] dataset[1] Unknown

Attached is a picture of the valuelist.

Ah, there is indeed a problem with 0 based array access, will be fixed in Servoy 2.1.2, in the meantime use dataset.getValue(row,col) (1 == first row/column)

getValue seems to be doing the same thing.

I changed my code to:

application.output("col 0 “+dataset.getValue(i,0)+” col 1 "+dataset.getValue(i,1));

and got the following result:

col 0 col 1 Client 1
col 0 col 1 Client 2
col 0 col 1 Client 3
col 0 col 1 Client 4
col 0 col 1 Unknown

(1 == first row/column)

so use:
application.output("col 1 “+dataset.getValue(i,1)+” col 2 "+dataset.getValue(i,2));

OK. Sorry I didn’t understand before.

That seems to work.

Its weird that the return value is in column two when I set it in the valuelist as the first column – but hey, whatever works!!!