Populate a column in a datagrid using a microflow or java to prevent redundant data
In our project we encounter a lot of functional requirements to display data in a datagrid that is actually not directly stored or related (modelwise) to the entity displayed in the datagrid. E.g. a column in a project data grid should show the name of the primary team associated with the project (while according to the model a project can contain multiple teams). Or a column should display whether an organization has due invoices dynamically. We are aware that several workarounds are available for achieving this functionality by e.g. creating additional relationships or storing data redundantly in the model. However these workaround also require a lot of extra functionality to ensure that the redundant data stays in line with the source data (e.g. event triggers, synchronization scripts that need to be run periodically etc...). Is it possible to display values in a column based on a microflow or java action (using the entity of the datagrid as an input)? E.g. by creating a custom widget (or by a new standard version)? This would enhance the mendix functionality considerably. Maybe someone already created a widget like this?
It is currently possible to add a virtual attribute to an entity, this value is calculated in a microflow when it's displayed and does indeed have the entity as an input. If you do heavy database calls in this microflow it could impact your performance though.
We're currently working on a major feature called Transient Objects where things like this are considerably easier. Objects then don't necessarily have to be stored in the database anymore to view them in a grid. That said, your exact request of adding an additional column with custom data is not part of this.
Sebastiaan van den Broek
I did some testing using virtual attributes. Although it covers most of our requirements, it is very unfortunate that it is not possible to search or sort on virtual attributes or use them in a XPATH on the datagrid. This would be a very convenient feature.
It is nice though that virtual attributes can be used in microflows.