onRecordSelection and related records

Hello,

As far as I can see there is a problem with the onRecordSelection method and actions I want to do.

I have a form A witch contains a header record (like salesorderheader) in recordview
On the form I’ve put a tabpanel, which contains a form B on salesorderline which is being shown in tabelview.

When I select another header record, I want to recalculate in the all the line records some field.

	// Method 'RefreshQTD'
	for (var i = 1; i <= controller.getMaxRecordIndex(); i++)
	{
		controller.setSelectedIndex(i)
		quantity_to_deliver = total_quantity_remainder	
	}

In my header I have an onRecordSelection method, that calls a method in the lineform:

forms.order_to_deliver_lines_lst.RefreshQTD();

Now the problem I have is that the relation has not been refreshed yet, so that the controller still works with the data of the previous record.

I also tried to use

salesorder_to_salesorderline.relookup()
forms.order_to_deliver_lines_lst.controller.relookup();

but both didn’t help. So I need the following:

Select record
Refresh form on tabpanel
Trigger onRecordSelection

but it seems that Servoy works like this:

Select record
Trigger onRecordSelection
Refresh form on tabpanel

In fact what I need is some kind of default method ‘AfterRecordSelection’ which is triggered just before the focus is given back to the user.

Has anyone a solution, or is this perhaps a bug in Servoy?

Thanks for your reply.

Servoy Developer
Version 3.5-build 513
Java version 1.6.0_02-b06 (Windows XP)

salesorder_to_salesorderline.relookup() 
forms.order_to_deliver_lines_lst.controller.relookup();

A relookup does what is says, relook at the initial values and add them to the dataproviders.
Not what you want!

You can force save data with controller.saveData() (prefix/object can differ based on the version of Servoy you use).
That should solve your issue.

Within my framework I can not use a saveData() because it is transaction based and a save is not allowed here. Save can only be done by pressing a special ‘Save’ button in my application.

Being in a transaction does not prevent you from saving data. I use transactions all over the place and have to use saveData() all the time because I use DB sequences.