array.concat

I’m trying to set a valuelist, called ‘_runtime’.

The value list should be all the names in the media_outlet table, plus all the alternates in the ‘LeadsAltSources’ valuelist.

(The value list in this case is for a “where did you hear about us” field. The media outlet table contains the magazines, direct mail campaigns and so forth, and the alt sources are things like “referral” and “saw a sign”.)

What’s wrong with the following method? It works if I return either the dataset or the altsources, but when I try to combine them with concat, I get the dataset and then ‘JSDataSet: size: 4, selectedRow: -1’.

var query = ‘select name from media_outlet’;
var dataset = databaseManager.getDataSetByQuery(currentcontroller.getServerName(), query, null, 10000 );
var nameArray = dataset.getColumnAsArray(1);
var altArray = application.getValueListItems( ‘LeadsAltSources’ );
application.setValueListItems( ‘_runtime’, nameArray.concat (altArray ) );

Cain:
I’m trying to set a valuelist, called ‘_runtime’.

The value list should be all the names in the media_outlet table, plus all the alternates in the ‘LeadsAltSources’ valuelist.

(The value list in this case is for a “where did you hear about us” field. The media outlet table contains the magazines, direct mail campaigns and so forth, and the alt sources are things like “referral” and “saw a sign”.)

What’s wrong with the following method? It works if I return either the dataset or the altsources, but when I try to combine them with concat, I get the dataset and then ‘JSDataSet: size: 4, selectedRow: -1’.

var query = ‘select name from media_outlet’;
var dataset = databaseManager.getDataSetByQuery(currentcontroller.getServerName(), query, null, 10000 );
var nameArray = dataset.getColumnAsArray(1);
var altArray = application.getValueListItems( ‘LeadsAltSources’ );
application.setValueListItems( ‘_runtime’, nameArray.concat (altArray ) );

Cain,

If you move the sample code in Servoy Editor into your method, you will
see that the function application.getValueListItems() returns a dataset not
an array.

You can also refer to the getValueListItems function description and
example in the printed Servoy Developer Edition Volume 2: Reference
Guide, in the “Methods” chapter, in the "Methods: Application section,
page 165.

NOTE: You can find the same information in the online Servoy Help
Navigator. Enter “getValueList” in the “Index” topic search criteria (make
sure to open the “Index” tab first); double click on Methods: Application
in the topics list below; then choose Tools>Find, enter “getValueList”
in “Find What” and press “Find Next” to highlight the getValueListItems
function.

Try this:

var query = ‘select name from media_outlet’;
var dataset = databaseManager.getDataSetByQuery(currentcontroller.getServerName(), query, null, 10000 );
var nameArray = dataset.getColumnAsArray(1);
var dataset1 = application.getValueListItems( ‘LeadsAltSources’ );
var altArray = dataset1.getColumnAsArray(1);
application.setValueListItems( ‘_runtime’, nameArray.concat (altArray ) );


Marc Norman
Servoy

Works like a charm.

Thanks!