controller.relookup()

Servoy Help states:
Function : relookup()
Description : Performs a relookup on the current record of a value that is based on a relation and has an auto-enter data setting (in Dataproviders > Properties).
Example : controller.relookup();

Why is it that this call only ever updates the current record ?

Sorry, I erred in my first posting.
Here’s what I meant to say:

Help Heading “Relooking up data”:

You can relookup data by:

  1. Using a method.
  2. Using the Relookup menu command.


To relookup data in an editable field for one or more records: Search for the foundset of records you want to relookup data for…Make sure you are viewing the foundset of records in Data (ready) mode - not Find mode.Click or TAB into the specific field you want to relookup data for.(You can select the desired field in any record of the foundset.) Choose Select > Relookup.

Why is it that this menu selection only ever updates the current record…not all of the records have the lookup performed on them ?

good question!

A function in which we could relookup a whole foundset would indeed be nice!

(it can be done now, by looping over the foundset)

databaseManager.refreshRecordFromDatabase(Object foundset, number recordIndex)

If you put in -1 as the record index, it will refresh the entire foundset. Not sure it it will do a relookup though?

It might even be a better way to use a calculation than a lookup in general. It does the same and can be recalced as David says. A lookup is something that comes from the other world…

Somehow, I’d trust a calc more.

I’d say that you cannot compare Lookups with Calcs:

A lookup is to refresh Servoy’s cached data (clientside only) if the data in the underlying database has changed.

A calc is something internally in Servoy, to return a certain value based on a “calculation” an one or more values that Servoy has in memory.

Paul

I don’t get it. What is a lookup of value “A” different from a calc that says return “A”?

Teh relookup function requeries the database to refresh the cached data in Servoy’s memory.

So, if you have updated your database through another application than Servoy and the servoy client allready had the data in it’s memory before you updated it in the database, Servoy will not see the changed data, unless you perform a relookup.

A calc is something completely different…

Paul

pbakker:
Teh relookup function requeries the database to refresh the cached data in Servoy’s memory.

So, if you have updated your database through another application than Servoy and the servoy client allready had the data in it’s memory before you updated it in the database, Servoy will not see the changed data, unless you perform a relookup.

A calc is something completely different…

Paul

Ok, now I am a bit confused :) There is the “lookup value” that is set in the dataprovider for a column which fills the column with a lookup value when a new record is created (usually through a relationship). I thought the relookup function retriggered this lookup into the column – which is different than refreshing the entire record from the server.

The code I gave above will refresh an entire dataset of records from the server (in case the records changed from a different source than Servoy) so if that is what you need, done deal. But I don’t think it will trigger the “lookup value” action.

I don’t use look up value columns hardly at all so a bit of a grey area for me. Wouldn’t mind getting it cleared up!

patrick:
I don’t get it. What is a lookup of value “A” different from a calc that says return “A”?

On a side note to this thread, there is a big distinction between the two. The parameters of the calc can change resulting in a new value other than “A”. A lookup value of “A” will remain that way until you relookup the value or change it manually.

So how you get to the value of “A” is the difference. Can be quite important sometimes!

A field whose contents are based on a LOOKUP is a database concept.
A field CALCULATION is an application-level concept implemented well in both Servoy & FMP.

I want a lookup event triggered.
The trigger event itself (say a menu selection or even a piece of java plugin code), should NOT need to understand any logic of the lookup. A calculation implies that the logic is understood and can even be created/applied at the point of requesting the “data update” - that’s not a valid asumption.
The busines rule for the lookup should be opaque to the user or application event trigger.