Hi Ankita,
If you want to save the value selected in a Combo Box and use it later, the approach depends on whether you are selecting a single value or multiple values.
For a single selection, you can use a persistable entity and store the selected value in an attribute. With the current Combo Box, you can configure the Database data source and use Store value to specify the attribute where the selected value should be saved.
For example:
UserPreference
SelectedValue (String/Integer)Configure the Combo Box to use UserPreference/SelectedValue as the store value. When the user selects an option, the value is stored in that attribute. Then simply commit the UserPreference object so that it is persisted in the database.
If the Combo Box is selecting objects from another entity, I would prefer using an association instead of storing only the displayed value. For example:
UserPreference 1---* / --> Option
Then configure the Combo Box with the association as its data source. This way you keep the actual selected object rather than just its text/value.
For multiple selections, use a reference set association. The selected objects are then stored through the association. The association changes need to be committed to persist them in the database.
So, in short:
I would avoid storing multiple selected values as a comma-separated String unless there is a specific integration requirement. Using associations gives you a much cleaner Mendix model and makes it easier to retrieve/filter the selected objects later.
You can also use the Combo Box's On change event if you need to execute additional logic immediately after the selection changes.
Depending on what you're showing in the combobox, you're changing an association, a boolean or an enumeration of a specific entity. To save whatever is selected, just commit the entity in question and that'll save the values in their appropriate places.