Using TYPE_AHEAD with global method valuelist

I am attempting to use a global method as the valuelist for a TYPE_AHEAD element on a form, but am having some trouble with it; currently, I have Servoy version 6.1

I connected to the example_data server and created a form using the “orders” table for the data source, selecting all fields in the form creation dialog. After creating the form, I changed the displayType for the employeeid element on the form to TYPE_AHEAD. Next, I opened the valueList dialog for this element, selected the Global method option, and clicked the dotted button to the right of the text box to create a new global method.

Next, I clicked the Scope button, which displayed a default name for the global method: getDataSetForValueList. I left the default name unchanged, and clicked the Create button. Finally, I clicked OK. The text box to the right of the Global method radio button was then filled in with the following text:

scopes.globals.getDataSetForValueList(displayValue,realValue,record,valueListName,findMode)

When I examined the sample code created by default for this method (by clicking the folder icon), I saw that it queried the employees table, selecting the employeeid and the concatenated first and last name. I saved the valueList that I created, calling it “employeesList”, and made sure that the TYPE_AHEAD element on my new “orders” form showed employeesList for its valueList property and that the dataProvider property for the element was set to “employeeid”.

I ran the solution in the Web Client, checking to make sure that the employee first and last name were changing as I navigated between orders. The problem was that when I attempted to type within the TYPE_AHEAD text box, I would see the list of employees appear for several seconds, but then the employee name that was originally selected for that record would overwrite what I was typing.

Am I misusing the global method valuelist in some way? Keep in mind that I did not change the sample code that Servoy automatically generated for the global method.

Thanks in advance to anyone who can help me.

Can you please post the code you are running ?

Here is the code, which is the sample code generated by Servoy when you first create a global method for a valuelist (I have not altered this code in any way):

function getDataSetForValueList(displayValue, realValue, record, valueListName, findMode) {

if (displayValue == null && realValue == null) {
// TODO think about caching this result. can be called often!
// return the complete list
return databaseManager.getDataSetByQuery(“example_data”, “select firstname || ’ ’ || lastname, employeeid from employees”, null, 100);
} else if (displayValue != null) {
// TYPE_AHEAD filter call, return a filtered list
args = [displayValue + “%”, displayValue + “%”]
return databaseManager.getDataSetByQuery(“example_data”, “select firstname || ’ ’ || lastname, employeeid from employees where firstname like ? or lastname like ?”, args, 100);
} else if (realValue != null) {
// TODO think about caching this result. can be called often!
// real object not found in the current list, return 1 row with display,realvalue that will be added to the current list
// dont return a complete list in this mode because that will be added to the list that is already there

args = [realValue];
return databaseManager.getDataSetByQuery(“example_data”, “select firstname || ’ ’ || lastname, employeeid from employees where employeeid = ?”, args, 1);
}
return null;

}