I have 2 fields on a form, that both have the same dataprovider (identification number column) attached. The 1st field has no valuelist attached, it just shows the identification number. The 2nd field has a valuelist with a fallback valuelist attached, it shows the name according to the identfication number.
The problem is, if I go to find mode and I enter a display value / name in the 2nd field. Then the 1st field shows also the entered name but this is not correct, because it is a number field.
I have attached the following global function to the valuelist br_boss_masterData_clients of the 2nd field.
function clientSearchSuggestions( displayValue, realValue ) {
/** @type JSFoundSet<db:/boss_sql/mandpara> */
var fs = databaseManager.getFoundSet( 'db:/boss_sql/mandpara' );
fs.addFoundSetFilterParam( 'mandnr', '<', 100000, 'Clients filter' );
fs.loadAllRecords( );
/** @type {JSDataSet} */
var result = null;
result = searchSuggestions( displayValue, realValue, fs, 'name', 'mandnr' );
return result;
}
function searchSuggestions( displayValue, realValue, foundSet, displayColumn, realColumn ) {
/** @type {JSDataSet} */
var result = null;
if ( !realColumn ) {
realColumn = displayColumn;
}
if ( displayValue == null ) { //field is empty
foundSet.sort( displayColumn + ' asc', true );
result = databaseManager.convertToDataSet( foundSet, [ displayColumn, realColumn ] ); //[display value, real value]
} else if ( displayValue != null ) { //field has text
var searchText = utils.stringTrim( displayValue );
var searchArray = searchText.split( ' ' );
if ( searchArray[ 0 ].length > 2 ) {
if ( foundSet.find( ) ) {
foundSet[ displayColumn ] = '#%' + searchArray[ 0 ] + '%';
foundSet.search( );
for ( var i = 1; i < searchArray.length; i++ ) {
if ( foundSet.find( ) ) {
foundSet[ displayColumn ] = '#%' + searchArray[ i ] + '%';
foundSet.search( false, true );
}
}
}
foundSet.sort( displayColumn + ' asc', true );
result = databaseManager.convertToDataSet(foundSet, [ displayColumn, realColumn ] );
} else {
result = databaseManager.createEmptyDataSet( 1, [ displayColumn, realColumn ] );
}
}
return result;
}
The valuelist br_boss_masterData_clients has attached a fallback valuelist br_boss_masterData_client_names that get its values from the table and it is configured to show the name in field an return the identification number in dataprovider.
If I attached the fallback valuelist, then I get the strange search behaviour, the search string (name) it is also shown in the 1st number field, which cannot be correct.