Hello All
I have two tables imports and import_positions. I need to have the next id (primary key) on the m-side, i. e. on import_positions. I made an aggregation idMax with type maximum on imports. On the imports (1-side) it works as expected, i. e. it gives the max number of id. But when I access this idMax field via the normal relationship on import_positions, I do not get the idMax number of the 1-side, but the id of the 1-side (I assume). I am not sure what’s wrong here.
Best regards, Robert
Aggregations in Servoy are in context: if you get an aggregation on a table it will get the max on the whole table, if you retrieve that through a relation it will get the max for that relation. In your case you can access the Max of that table by retrieving it on a form that is based on that table. eg
var vmax = forms.import_positions.NAMEOFTHEAGGR
Hello Jan
Thanks for the solution, it works. I am still wondering, for accessing a aggregation via a relationship, this behaviour never makes sense, does it? The aggregation value on the other side of the relationship has only one value, ever. I assume the behaviour is because the relationship acts (for this case unwanted) like this?
Best regards, Robert
jaleman:
Aggregations in Servoy are in context: if you get an aggregation on a table it will get the max on the whole table, if you retrieve that through a relation it will get the max for that relation. In your case you can access the Max of that table by retrieving it on a form that is based on that table. eg
var vmax = forms.import_positions.NAMEOFTHEAGGR
In most situations it does make sense. Imagine an order_details table with a SUM(PRICE) field. If you place it on a related Order form it will automatically get the total for you. Same for max to for example figure out the most expensive line item, etc.
Hello Jan
Could it be that generally spoken that from the m-side to a 1-side relationship the implemented behaviour makes sense but not from the 1-sid to the m-side, but I am not sure about that.
Best regards, Robert
jaleman:
In most situations it does make sense. Imagine an order_details table with a SUM(PRICE) field. If you place it on a related Order form it will automatically get the total for you. Same for max to for example figure out the most expensive line item, etc.
I’d say the other way around, in general you want summary functions to go from 1 to N. From N to 1 it doesnt make any sense to performm any summary function as there is only 1.