Screen refresh with value lists

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()
}
}

didn’t test it yet but i see youre problem
And the typeahead field is not made for this. I don’t know if i can make this work.
Because if you use a valuelist that has a different return type then display then a typeahead should be ‘readonly’ (just as a combobox would be) With readonly i mean that you can ofcourse type stuff in it. But you have to select a value out of the list or else you will get null no matter what you type…

This is because i can’t return anything if you use a different return then display. I can’t return a String (the name) to the record because you are storing a integer.. (the id)

so what is in your example k_comp? is that a int field?? then you can never have a name in it.. Or are you somehow mapping the pk (a integer) to a string column (k_comp)??

currrently the typeahead and the underlying dataprovider system isn’t build for youre situation!

pk is text. It is a concatenation of the table name (‘Companies’) and the sequential id field. This provides a simple ‘Universal’ key within the solution.

Typing the company name in the typeahead field does, in fact, return the pk appropriately. Typing a value that isn’t in the list does not return a null; instead, the typed value is returned directly to k_comp (i.e. ‘New Company’).

Also, the method enters the pk appropriately.

I’m not sure why this keeps coming up, since that isn’t the part that’s not working.

The issue is that even after the method has appropriately set the k_comp field, the name doesn’t display correctly until I force a refresh.

Is there something else I can provide to help you recreate this? I’m afraid I’m a bit of a newbie. Would sending you an exported repository help?

Hi Cain
Can you export your solution from the repository and attach it to this thread with a description of where this issue is occuring and then we can have a closer look.

:)

Here goes. The solution uses a named database ‘extensitech’.

The issue is on the form called Addresses_Form.

first i changed youre method:

if ( !addresses_to_companies.pk ) //run only if there's no valid company chosen...
{
	if ( k_comp ) //..but a value has been entered 
	{
		forms.companies_form.controller.newRecord() //create a new company record
		forms.companies_form.company_name = k_comp; //enter that invalid value as the new company's name
		controller.saveData()
		k_comp = forms.companies_form.pk; //set the valid key, using the list form
		controller.saveData()
	}
}

because you first need to save the company before setting the pk value back to k_comp. If you don’t do that then the lookupfield will not be able to get the display value and then it will show you the pk itself.

But i even with the new method i still have found another problem with the way this works. I have fixed this for 2.1.2

Thank you!

Also, thanks for everyone’s patience while I repeatedly fumbled the explanation of this issue. From my years with FMP clients, I know how bewildering it can be to deal with a newbie who doesn’t ‘speak the language’.