Get the object associations in an expression - for example visibility

Hi Mendixers, I’ll try to ask my question as clear as possible. Let’s say for example I have a Note entity.  I have: Note 1 – * OtherNote Note 1 – * Location On a page I have a dataView Note. With a few buttons. Now I want to play (visibility etc) with those buttons depending on the values of those other entities. For example: if OtherNote’s attribute x has that value then … AND if Location’s attribute y has that value then … It’s not possible to reference to OtherNote and Location in CurrentObject in my expression. (screenshot) I know it’s possible with microflow but that’s not an option for this situation (visibility). With a microflow my button will be still clickable. Hopefully my question is clear... Can someone help me with this please?  Thank you in advance!
3 answers

check this I think it would help you

This widget will hide or show its parent element, based on the result of a microflow or nanoflow returning a Boolean such that more complex visibility conditions can be composed.


there are many location  associated with the same note how would you select a specific location to change the visibility

according to its value ?
you need to change the association to 1 to 1
note 1 to 1 location
or make the note the owner of the association
othernote 1 to * note

add a dataview inside the first dataview and select location over assoication
and add the button to it now you can change its visibility based on an attribute inside location

do the same for othernote


It's a bit of a workaround, but what we usually do in such cases is create a non persistable helper object to determine visibility. So for instance, when you open this page, do so from a microflow where you create a VisibilityHelper object. In the object, put a boolean attribute _buttonvisible. Set the boolean based on the expression you wanted to use. Also associate the object you used as a page parameter previously, so that you can still use it on the page.

Now pass the helper object to the page. You can now simply use the _buttonVisible attribute to set the visibility of your button.

As an aside: never rely on visibility alone for security. If users should never be able to use the button if they don't meet requirement x, y and z, then check that requirement when the button is clicked either way.