How to display non-persistent values in dropdown or reference selector
0
I am importing data through REST. I want to save it as non-persistant. The relevant JSON looks like this: { "Name": "stringParam1", "Value": "op1", "valueLimited": true, "valueOptions": [ "op1", "op2", "op3" ], "ValueDefault": "op1" } My domain model now looks like this (by using auto import mapping): I want to add a drop-down list or reference selector (or similar), so the user can select an option. When user makes a selection, I want to trigger a microflow and save the selected option into the "Value" field on the "StringParameter" entity. The reasoning is that if ValueLimited=false, I will display a standard text-field for the Value. But if ValueLimited=true, I will display the dropdown instead, and save the selection to the Value field. I have tried a bunch of things, it seems to be possible with a reference selector, but I cannot figure out how to configure it properly. Currently I cannot even display the options in any way...
asked
Niclas Busck
2 answers
1
I have spent multiple days on this now, and I finally found a solution that works, even if it probably is a bit ugly.
I used the "dropdown container" widget. In it I have a listview, which have data source as a microflow. In it I retrieve the option entities, and return the list. I then display the attribute I need in a text field, next to it I add a button. The button triggers another microflow which gets the option entity as parameter, here I save the option into my main value attribute.
answered
Niclas Busck
0
Create a Non-Persistent Entity:
Create a non-persistent entity that represents the data you want to display in the dropdown.
Create a Microflow to Retrieve Data:
Create a microflow that retrieves the data you want to display in the dropdown. Use the "Retrieve" action to fetch the non-persistent entity instances.
Create a Microflow to Populate Dropdown Options:
Create another microflow that will be used to populate the options for the dropdown. Inside this microflow, use the "Create Object" activity to create instances of the non-persistent entity and set their attributes based on the data retrieved in the previous microflow.
Use the Dropdown Widget:
In your Mendix page, add a Dropdown widget.
Configure the dropdown to use the non-persistent entity as its data source.
Use the microflow created in step 3 to populate the options for the dropdown.
Trigger Microflows on Page Load or Events:
Trigger the microflows created in steps 2 and 3 when the page loads or when a relevant event occurs, such as a button click.
Set the Selected Value:
If you need to set a default or initial value, use another microflow to set the selected value of the dropdown.