Microflow attributes calculated too often

4
Why are microflow attributes calculated that much? Even when not using (approaching) an attribute, at every retrieve of that object the microflow is calculated. So when retrieving 1000 objects in an MF which has 3 microflow attributes: 3000 microflows are executed, mostly completely unnecessary because the attribute is not used in that microflow. We have some MF attributes pure for UI reasons (because of conditional visibly limitations) and they are slowing the application down. Is there a reason for this behaviour or should I file a ticket?
asked
3 answers
0

Herbert,

The microflows do not seem to be triggered on the retrieve. In a test project I created an entity with a calculated attribute and a second microflow that retrieves all the records from that entity. Added a breakpoint on the calculated attribute and used the second microflow to retrieve the records. This will not trigger the calculated attribute microflow. When adding a commit action without refresh on the retrieved list of records will not trigger the microflow for the calculated attribute. Only when adding a refresh to the commit action, refreshing the entity with the calculated attributes will trigger the calculated attribute's microflow. This is however default understandable behavior, so my guess is that you are refreshing your records in the microflow that retrieves the 1000 objects and as you're using the attributes for display purposes (UI), refactoring the entity to non-calculated attributes is your best option for performance.

answered
0

One addition: beside performance issues caused by MF attributes it's also a great way to get regression errors in your application.

Recently in one of our projects: a MF attibute was added to the object Invoice. A UI helper attribute to give a notice to the user depending on their roles. But also nightly batch processes are retrieving invoices. Now this microflows where also triggering the MF attributes (even without usages!!) and the batch processes crashes because currentuser is not in scope.

So I really think this that microflow attributes should be redesigned and calculated only when they are approached. Not when they are retrieved.. It's also actually more accurate to calculate when approached.

answered
0

Herbert, you are correct with your statement that microflows are being executed to often. This is something you should file a ticket for.

I have seen this as well, however in your original post you are refering to modeler 4.1.0? I'm not sure exactly about that Mendix version, but I know absolutely sure that this happens anywhere from 4.6.x and higher (in Mendix 5 as well).

In my opinion the calculated attribute should only be triggered when it is actually being used. However the platform currently does it to often. It executes the calculated microflow when retrieving the object in microflow, and whenever you actually use the attribute in an expression.


As you mention in your comments, datagrids do not execute calculated attributes when they are not shown because of the schema. Only the attributes that are shown are being executed.
In Mendix 4.x opening a dataview can trigger the execution of the calculated attribute as well.
In Mendix 5.x you can configure this, in Mx5 you can also choose to render the dataview using a schema. This should behave similar to the datagrid schema.

answered