Conditional visibility for a button based on association - not supported, so how then?

0
Wow, lots of questions and posting on this subject over the years, as I searched for an answer, but I’ve still not found how to accomplish this. I have an entity (DocInfo) which stores information about a document (like title, description, whether it’s public, the author/owner, etc..) I have another entity (DocAccess) which is a join table between DocInfo and the System.User entities. In this DocAccess table stores the access type (using a enumeration of ‘Read’ or ‘Write’), and then it is associated to a User and to a DocInfo record. So, for a given DocInfo record, a user may or may not have an entry in the DocAccess, and if they do, it will either specify the user has “Read” access or “Write” access. Within my page, based on the DocInfo object, I have a button titled “Edit”. This button should only be visible if the current user is either the ‘owner’ of the DocInfo record OR if the user has ‘Write’ access defined in the DocAccess entity for this DocInfo record. I’m clear on the “if the user is the owner” portion of my criteria (I have “Store ‘owner’” set on the entity, and then my visibility expression includes “($currentObject/System.owner=[%CurrentUser%]”. Where I’m struggling is the portion of the expression that says  “or the current user has a record in the DocAccess entity with the value of  ‘Write’ access for this DocInfo record”. The issue I seem to be bumping up against is that associations are not allowed within Visibility expressions, so I am stumped on how to get a peek at the DocAccess entity to look for this user and then look at the AccessType value. I thought maybe a microflow that returned a boolean or something of that sort, but Visibility expressions for buttons don’t support calling a microflow. Below is my domain model to help, and includes the other entities in my project. I thought I was getting the hang of this, and then I seem to smash right into another wall.    Thank you in advance for any help.
asked
2 answers
3

Hi Scott,

Hope this widget helps you to set the condition to the button via microflow

https://appstore.home.mendix.com/link/app/110010/

 

Thanks

Bharathidasan

answered
1

A solution could be to add a dataview of the DocAccess entity inside the dataview of the DocInfo entity.

Place the Edit button inside the innner dataview and set the visibility based on the AccessType attribute that can now be used in the conditional visibilty expression.

answered