Newbie to Mendix question about when to run a microflow automatically on maintenance on an entity attribute
I am brand new to Mendix and playing around with some concepts. I have an app our company uses basically as an ERP system in Quick Base and I want to recreate some of it in Mendix to see how development feels as the capabilities seem far superior. That being said my first step is to create an Employee Directory for our employees. I have created a module for EmployeeManagement and I have created an entity Employee. I created several attributes (First Name, Last Name, FullName, WorkEmail, PersonalEmail, OfficePhone, MobilePhone. I want FullName to be stored attribute as employees do not change names so no reason to calculate that on every database read. I created a microflow to run on the entity “before commit” and it has a single object, a change object. In that change object I set the item being changed to my Fullname attribute and in the expression I put $Entity/FirstName + ‘ ‘ + $Entity/LastName So my questions are: Is this logic right? I am thinking that by using this as a before commit I do not need to commit to the database because if I am understanding correctly this will run automatically everytime someone creates, updates, or modifies the entity. Is this in general the correct idea and way to do this? Any steps I am missing?
You are totally correct: do not commit in a BeforeCommit-event. It would trigger an error, because it would create a loop.
It is an option, but it will make FullName get calculated time and time again even if FirstName and LastName have not changed. The other option: You only need to change FullName if FirstName and/or LastName change. So better is an onchange on the pages where you can change the FirstName and/or LastName.
Yes, looking at Marketplace.mendix.com. There is Person, doing exactly this. And Company, if you want some more pre-built functionality. They depend on SystemManagement, so download that one as well.