Guess sibling objects when calculating an attribute
In Multi language design models. Results of a knowledge network day. they suggest using a calculated attribute. “The reason why a calculated attribute can be used here is because it only retrieves over an association the object with the right translation” I think it’s no longer true because Mendix DOES NOT cache pristine objects so even when using same Retrieve by Association within a request then every time they will be retrieved from DB. To make an efficient CAL_ microflow that uses the info from parent associated objects we need to implement our own caching. In particular, we need to pre-fill a readahead cache of parent objects when the CAL_ microflow is called for the first time during the request. To do that we need to know for which objects the CAL_ microflow will be called in the future. For now, the idea is to collect all the microflow variables from the Action stack and extract the objects with the matching type. This will require using the non-public methods: com.mendix.modules.microflowengine.microflow.Microflow.getScope() com.mendix.modules.microflowengine.microflow.Scope.getVariables() Sometimes there’s no microflow Action in the stack. This happens when a calculated attribute is used to construct a data response for a widget or a REST call. In this case we don’t yet know how to guess the sibling objects. Ideally, there should be a mechanism to track all seen objects during the request.
This has nothing to do about cache. Mendix will always do the retrieve for a calculated field hence the reason to only use this if you must. The reason why it is still ok here is because this retrieve is real fast since the amount of objects in the table is small and due to the XPath constrain to only retrieve the correct translated object.