Entity State Contention In Microflows

We originally had a Template grid in place that had multiple buttons in it.  For example, Claim and Release buttons which were wired to specific microflows.  This worked well except that Template Grid was had the following issues.   Template Grid did not support sorting If you clicked the header of the Template Grid it would execute the default action You could not resize columns Etc.   So we converted it to a Data Gid and used an enumeration along with the Data Grid Extension from the App Store to display the buttons in a column.  The trade off is that you can only have one microflow assigned now instead on one per button as in the case of the Template Grid.  So we created a microflow that would determine which sub flow to call.  This works fine as one would expect.  We simply look to see if the entity’s Claimed status is True, and if so we assume the user clicked Release.  Likewise, if the Claimed status of the entity is False, then we assume the user clicked Claim.  In the microflows we update the enumeration which causes the buttons state to respond accordingly in the UI.   The problem arises when we introduce multiple users in different browsers.  If user 1 clicks the Claim button, everything works as expected and the entity is assigned to user 1.   However, user 2 still has their screen up and it look like they can claim it to.  So user 2 clicks the Claim button.  This call the single microflow with the logic to determine which sub microflow to call.  The logic looks at the entity to determine if it was claimed and magically it is because user 1 claimed it.  But this is bad because user 2 will be sent down the path of Release, which is not the intention since they clicked the Claim button.  There is no context as to what the entity state was when user 2 clicked the button.  It is as if it always pulls the latest version from memory on the server if there is one available.     What are the best practices for handling these scenarios.  
1 answers

Hi Jeffrey,


This is not a Mendix issue per se, just a general issue when working with applications where multiple users have editing access on the same data.

There are several things that you can do to improve the user experience but to the best of my knowledge there is no easy and complete solution.

1. Refresh your data grid periodically e.g. every minute. This way data will be updated. check the timer widget for this - https://appstore.home.mendix.com/link/app/27/Mendix/Microflow-Timer

2. Set up the application so  that only a limited number of users (best case only 1) have editing over the same data. e.g. for each Fund associate a user that is responsible for editing it.

3. When updating the Fund check if the state has changed by retrieving the same Fund from DB. If the state has changed then inform the user about this and refresh the object so that they see the latest change.


Hope this helps,