I had previously posted this issue under http://forum.servoy.com/viewtopic.php?t … sc&start=0 .
I’ve corrected code errors that have been pointed out, and tried all the suggestions. It appears that the remaining display issue is a bug.
Servoy 2.1.1, Windows 2000 Pro.
I have a typeahead field for “Company”. The value list shows company name but returns company key (‘pk’).
On datachange, a method runs to check that a valid company has been chosen. If not, the method creates a new company with the value entered, and brings back a valid key for that new company, to put in the field.
All of this works fine, but on the screen the key I’ve brought back shows in the typeahead field, instead of the name. The only way I’ve found to “refresh” the value is to go into Designer mode, or to shut down the solution and re-open it. I’ve tried application.updateUI, controller.savedata, setting the value on another form, resetting the value, and even tried setting the company name in the typeahead field instead of the key.
The correct values are being returned, as demonstrated by the fact that I can see them by placing other copies of the fields on the form, and also by the fact that the display is correct after design mode or solution restart. See attached document for screenshots.
Here is the method I’m running. This should be fairly easy to reproduce.
if ( !addresses_to_companies.pk ) //run only if there’s no valid company chosen…
{
if ( k_comp ) //..but a value has been entered
{
var a = k_comp //copy the invalid company name, which is now in the key field
k_comp = ‘’
controller.saveData()
forms.companies_form.controller.newRecord() //create a new company record
forms.companies_form.company_name = a //enter that invalid key value as the new company’s name
var b = forms.companies_form.pk //capture the valid key for that new company
forms.addresses_list.k_comp = b //set the valid key, using the list form
forms.addresses_list.controller.saveData() //save
controller.saveData()
}
}