ReferenceSelector

0
Hi I have started working in mendix. I am using "ReferenceSelector" in my app. It is working fine, it is populated with values. But when i load the page it shows empty, when I click on the button which looks like dropdown the items been shown. My question is that how I can prevent it from showing empty on page load/ or else how i can set default value/item in my "ReferenceSelector"? Thanks, Iqbal Kaur.
asked
1 answers
3

That all depends on the way you use that reference selector. The way you describe it, it's simply the association between Entity X and Entity Y. If you show this association through a reference selector on any form, it will by default show 'empty'. Clicking on the dropdown then reveals all instances of Entity Y that are available from the database, to which you can reference.

If you want a default value for the reference selector, you should select your value before showing the form. So instead of pointing to "Page" from your navigation, you should point to a "Microflow" which ends with the Show form action to show your "Page". This way you can retrieve the value from Entity Y you want prefilled on your form and set the value of the EntityX_EntityY association to that retrieved value.

I created an example through Model Share below:

<iframe width="100%" height="491px" frameborder="0" src="https://modelshare.mendix.com/models/18caabb3-def1-46c0-a378-65ab45d0c67e/referenceselector-prefill-example?embed=true"></iframe>
answered