I have a tabpanel using a relationship that includes a global on the left side (pk) of the relationship. Works fine. The tabpanel displays records with a tick box or check box. I want to build a dynamic value list that includes just the items ticked.
Much to my surprise the same relationship that controls the tabpanel does not work when used in a value list. Using the unmodified relationship the combobox presents a drop down of blank, nada, nothing. I suspect, but am not sure, the problem is the global on the left hand side of the relationship.
Anyone have recommendations on how to achieve the functionality I want? One possibility might be to assemble an array of the ticked items and use that to generate the value list. Not sure how arrays can be used in VLs. Other options?
I’ve adapted some sample code Maarten posted in Forum Topic 618 on how to use arrays in value lists. In Maarten’s code he uses a SQL query to gather up all the records of a table.
In my approach I’m pre-loading the form with just the records I want. Then I’m creating my arrays. However the result is I’m ending up with a single line value list showing “Fruit, Cereals” instead of:
Fruit
Cereals
Also when I use the value list it’s not returning anything, is leaving the combobox field empty.
Any ideas?
var max = controller.getMaxRecordIndex();
var names = ''; // iniate variable
var id = ''; // iniate variable
for ( var i = 0 ; i < max ; i++ )
{
var current = controller.getSelectedIndex();
names = names + name + ','; // concatenate field contents separated by a comma
id = id + tableid + ','; // concatenate record id's separated by a comma
controller.setSelectedIndex(current + 1);
}
controller.setSelectedIndex(1);
var length = names.length;
names = utils.stringIndexReplace(names, length - 1, 2, ''); // trim the final comma
var length = id.length;
id = utils.stringIndexReplace(id, length - 1, 2, ''); // trim the final comma
var nameArray = new Array(names);
var idArray = new Array(id);
application.setValueListItems('valuelistname', nameArray , idArray );
I’ve solved one problem and vastly simplified the method.
var nameArray = databaseManager.getFoundSetDataProviderAsArray(foundset,'name');
var idArray = databaseManager.getFoundSetDataProviderAsArray(foundset, 'recordid')
application.setValueListItems('valuelistname', nameArray , idArray );
I’m now setting the array properly and indeed the combobox now displays:
Fruit
Cereals
on separate lines.
However it’s returning nothing, nada.
The Value List is set for “Custom Values” as Maarten noted. My intuition suggests something more is required to instruct the VL to return the second column of the array.