Hello, maybe I am too stupid to do this or it doesn’t work as expected.
I have a value list that derives an ID (not shown but returned) and a value (shown but not returned) over a relationship.
When I use application.getValueListItems on this value list I can see that an array is built but both the displayvalue and the realvalue are undefined.
The same happens when I use the sample code that calculates “the strange total”.
Am I missing something?
RC13 on XP.
Thanks!
var x = application.getValueListItems returns a JSDataset inside x
(when you hover with the mouse over the function, you can always see what kind of object is returned.)
var dataset = application.getValueListItems("categories")
//dataset will look like this:
//displayValue1 returnValue1
//displayValue2 returnValue2
//displayValue3 returnValue3
for( var i = 1 ; i <= dataset.getMaxRowIndex() ; i++ )
{
dataset.rowIndex = i;//sets the row
dataset[1]; //gets the value of column 1(displayValue)
dataset[2]; //gets the value of column 2(returnValue)
}
Also check out the DatabaseManager>JSDataset
to see more possibilities with JSDataset.
I used exactly your code. My value list has two values, I copied the name from the value list definition not to make a typing mistake. See the attached picture to understand my problem.
In your code i never gets a value so the if-clause is never run into. Those arrays being undefined is exactly my problem.
did you set the rowindex??
var dataset = application.getValueListItems(“categories”)
application.output(dataset.getMaxRowIndex());
dataset.rowIndex = 1;
application.output(dataset);
what is the output then?
wf_ESSv2_pitc_alone_2011March15H1055.servoy (351 KB)
Change the code into:
var displayValue = dataset[1]; //gets the value of column 1(displayValue)
var returnValue = dataset[2]; //gets the value of column 2(returnValue)
…and step through the script with debugger, checking if these two var’s are getting filled.
all of this can’t work in my eyes since dataset is undefined. The result is
0.0
JSDataSet:size:0,selectedRow:1
0.0
JSDataSet:size:0,selectedRow:1
Maarten’s suggestion doesn’t change anything since the if-clause is never met because geMaxRowIndex() delivers 0.
I am quite confident that I know how to handle datasets in general but here there is simply nothing returned.
then we need an example.
Because youre valuelist is just really empty can’t help you further without seeing youre (example) solution…
OK, attached you will find an example solution “Test” with database file. I had to create a single solution for this since I cannto send you my “monster” solution to check this out. At least the problem was reproducable.
Please don’t ask me why I do the things I do, because here, things have been torn out of context. Anyway, the sample includes all components to demonstrate my issue.
I have the impression that the problem comes from the definition of the value list having a global on the left side of a relationship. I haven’t played with other definitions, but this is probably where it goes wrong.
Thanks for looking at it.
please can you re-export youre solution but then with sample data?
then i don’t have to do all the work for a adding database files.
I did include data plus the database file?!
Enclosed you find an export (again) with data.
thx. seen the problem now.
Don’t know if this will or can be fixed for the final of 2.0 we must discuss that first.
of course for now you can also get youre values this way:
for( var i = 1 ; i <= data_to_value_list.getMaxRecordIndex() ; i++ )
{
data_to_value_list.recordIndex = i;//sets the row
var displayValue = data_to_value_list.name
var returnValue = data_to_value_list.apply_for
}
just go right through the relation.
OK. Thanks for checking it out.
I’ll use that workaround in the meantime.
Could you give some short information about what the problem is or in what situations getValueListItems won’t work so I don’t loose time in other occasions?
getValueListItems on related valuelist don’t work quite right
Use the relation it self if you want the data.
Updated the tooltip text/sample code/docs … “Get all values from a custom or database type value list”
It is not created to be used on related valuelists.