How can I get the following to work?
function UTIL_choiceListToArray(valueList, arrayName, arrayType) {
if(valueList && arrayName) {
var querytext = "";
if((arrayType) && (arrayType == 'name')) {
querytext = "SELECT choice_list.chc_item_name FROM choice_list WHERE ";
} else { // default to obtaining the code value --
querytext = "SELECT choice_list.chc_item_code FROM choice_list WHERE ";
}
querytext += "choice_list.valuelist_name = \'" + valueList + "\'";
var ds = databaseManager.getDataSetByQuery('SELPA_Mgr_SQL', querytext, null, 1000);
ds.sort(1,true);
arrayName = ds.getColumnAsArray(1);
}
}
Right now the dataset is populated, but the array is empty. I’ve tried passing both an array object and a string (name) as arrayName.
Thank you,
Don
Hi Don,
what is this ‘arrayName’ argument in the method?
Is this a string referencing a global/form variable or something?
if so and - like you say - the dataset is populated and ds.getColumnAsArray(1) gives you the array you want to store
this should do the job in case of a global variable:
globals[arrayName] = ds.getColumnAsArray(1);
kwpsd
March 8, 2012, 5:50pm
3
You could do something like this:
var arrayName = UTIL_choiceListToArray(valueList, arrayType)
function UTIL_choiceListToArray(valueList, arrayType) {
if(valueList && arrayName) {
var querytext = "";
if((arrayType) && (arrayType == 'name')) {
querytext = "SELECT choice_list.chc_item_name FROM choice_list WHERE ";
} else { // default to obtaining the code value --
querytext = "SELECT choice_list.chc_item_code FROM choice_list WHERE ";
}
querytext += "choice_list.valuelist_name = \'" + valueList + "\'";
var ds = databaseManager.getDataSetByQuery('SELPA_Mgr_SQL', querytext, null, 1000);
ds.sort(1,true);
return ds.getColumnAsArray(1);
}
}
Returning the array did the trick.
Thanks so much,
Don