I have a dynamic value list based on a global method fetching values in a table (codes) containing all my value lists.
In a data table, I happen to have “old” values which aren’t stored in the “codes” value list table.
My goal : display the old value to the user in the form through a combobox, the old value being shown top of the list, separated by a space from the standard values in the list, so the user knows what he is dealing with.
I built this simple (simplified) method
function getDataSetForValueList(displayValue, realValue, record, valueListName) {
var key = 'valeur';
var field = 'valeur';
var table = 'codes';
var filter = 'app_module='+SOME_GLOBAL+'\'';
var maxReturnedRows = 100;
var query = 'SELECT ' + key +
' FROM ' + table +
' WHERE valueList_name=\'type_prestation\'' +
' AND ' + filter +
' AND active = true' +
' ORDER BY ' + field + ' ASC';
// params in real code
var dataset = databaseManager.getDataSetByQuery(serverName, query, null, maxReturnedRows);
// search "details" value in record in the list
var found=false;
for(var i=0; i<=rows; i++){
var value = dataset.getValue(i+1, 1);
if( value == record.details ) {
found=true;
break;
}
}
// Is value known or is it something else ?
if (record.details && !found) {
dataset.addRow(1, new Array("-"));
dataset.addRow(1, new Array(record.details));
}
return dataset;
}
Now, even if Servoy calls this global method several times when showing the form or entering edit mode, it is as if Servoy would cache the dataset independently because I keep getting an old value from one record while editing other records.
Has anyone a clue on what’s going on, on how I can fix this ?