Question

When are expression fields set (loaded/available?)

  • 10 September 2020
  • 8 replies
  • 79 views

Userlevel 2
Badge +3

hi all, 

 

I was wondering, can anyone shine a light on this.  

I have a record (shipment - saved). I edit and add a Ship. This ship has some info like time of departure. 
These field are displayed in my Shipment screen as Expression fields. 

However, when i Edit Shipment, with the looking glass Add  a new Ship, insert this… the expression fields remain empty until I save the shipment. 

Is this the normal flow of things? It happens in both web gui and windows gui. 

 

I of course would like the fields to be refreshed after inserting a new ship and connecting it to my shipment (so without the save).

 

Who knows?! 

 

Alex

 


8 replies

Userlevel 7
Badge +14

Hi Alex,

Expression fields will update on the basis of data in your screen. When I try this in the project I work on, it works like a charm. Most importantly, what is the code behind you expression field? What does it select and how?

My project example:

select t.translation
from translation t
where t.name = t1.name

The expression field should use t1, because t1 is the table alias of, in your case, Shipment. Probably your code should look like this:

select d.departure_time 
from departures d
where d.ship_id = t1.ship_id

Hope this helps your further!

Kind regards,
Mark Jongeling

Userlevel 2
Badge +3

Hi, well it works fine. Without saving. But only when we use an already existing record in Ship.

When adding a new record in the table Ship (through Shipment [looking glass]) it does not. 

So I assume my query is ok, but that somehow the app loads the newly added record after me saving the Shipment-record. 

Userlevel 7
Badge +14

Hi,

I now understand what you mean. It looks like the GUI doesn't use/show values that are freshly new. Sounds strange to me. Could you report the issue in TCP with screenshots and perhaps a video of it? My colleagues then can assess it and fix it :wink:

Kind regards,
Mark Jongeling

Userlevel 2
Badge +3

@Mark Jongeling  you can reproduce the issue I understand from your reply? 

Sure, will do. Would be a nice  fix. 

Userlevel 7
Badge +14

@Mark Jongeling  you can reproduce the issue I understand from your reply? 

Sure, will do. Would be a nice  fix. 

I currently can’t reproduce it because in my project we don't use many expression fields this way. We save the data in database fields, that way it's possible to fill them with the default procedure. Then this issue doesn't present. But I do understand what you meant, hence my words.

Userlevel 3
Badge +1

Hello Alexander,

Yes, this is as expected/designed;

Expression fields are set after confirming your action (in this case saving the record of ‘Shipment’), because expression fields CAN have a lot of impact (for instance, a heavy query in this expression field). If this expression field would be activated after every user action in the form, this could negatively influence the performance of your application.

The way to achieve your requested ‘refreshed’ data, is to use database fields under ‘Shipment’, which are maintained with a default procedure, which alter the data directly when you add/update/delete an underlaying detail (Ship).

Userlevel 2
Badge +3

Hi Bart, 

I do get the feeling that Expressions work instantly when I use already existing data. So this only goes for newly entered data? For example, when I entered a weight in metric, the expression with the imperial is shown instantly. 

So, is there a difference between newly added Ship and already existing ships? (the data in this case). 

Alex 

 

 

 

Userlevel 6
Badge +4

Hi Alex,

Expression fields are always evaluated on selection. This happens when you simply list the data, but also when you go into edit mode.

While in edit mode, the expression fields are only evaluated when one of the dependencies change. The dependencies can be viewed in the data modeler, they are the fields with the t1-prefix.

As long as the values of these fields do not change, the expression will not be re-evaluated. This works fine most of the time, but in your case something unrelated to the dependencies causes the value to change. In your case, the ship_id does not change yet the values loaded from the related ship have changed. The mechanism cannot detect this.

I hope this explains why things work differently than expected. There are some work-arounds possible, like using default logic to update the expressions instead of relying on the mechanism itself.

Reply