How to use calculation attribute

0
Hi there, We have a request from a customer who wants to display the time in the following format E.g., July 31, 2:00 AM → July 30, 26:00  (means, 24+2) Apart from the Date And Time Attribute, I'm trying to have an Attribute of String to display this. I'm thinking of three things. 1. set [Attribute_2] to “Calculated” and Make a MicroFlow to calculate it. 2. set [Attribute_2] to "Stored" and create a MicroFlow to calculate it and set up MicroFlow for Before Commit. 3. Call MicroFlow to calculate and ChangeObject by myself whenever I should calculate. Regarding 1. There are a lot of date attributes. So, in this case, it might slow down when we retrieve or when we migrate the data. This is a concern. Regarding 2. I'm worried about [BeforeCommit] that Mendix is not fast enough to Insert, so if it happens a lot, it might cause performance concerns. Regarding 3. It reduces performance concerns because the programmer has a choice, but instead increases the likelihood of forgetting to handle it. We are well aware that there is no magic. However, if anyone has any usual methods or ideas, I would appreciate it if you could share them with me.   Regards,
asked
2 answers
3

Maybe you could create a helper attribute and add a before commit event to set the helper attribute to your expected foramtted value. Then you can display this attribute in overviews. This action would run only on commit and not every time on calling the retrieve.

answered
3

If it is in the before commit, you can be sure it is set. You only need to make sure not to commit without events.

A calculated attribute is definitely worse than doing it in a before commit. And, some things are just not working with calculated attributes (using them in xpath statements,...). I would go with Gerrits solution.

answered