Combo box retrieve

0
I have a Combo Box for designation in Mendix. The designation table (designation) contains code and abbrevation. The employee table only stores code in the master table.During edit, I retrieve the employee data from the master table using an OQL query and correctly get code, but the Combo Box does not automatically display the corresponding abbrevation.How should the Combo Box be configured so that the retrieved code correctly shows the abbrevation in edit mode?
asked
2 answers
0

The main point is that a Combo Box does not select an item based only on a matching text or code value. It usually selects based on the actual object reference (association).


So if your Employee entity only stores a code attribute, but your Combo Box is showing values from the Designationentity, Mendix does not automatically know which Designation object should be selected. It only knows the employee has a code string or integer. It does not yet have the related Designation object.


That is why, in edit mode, you may correctly retrieve the employee code from OQL, but the Combo Box still does not show the expected abbreviation.


The cleanest Mendix way is to use an association between Employee and Designation.


For example:

  • Employee stores or references one Designation
  • the Combo Box is bound to the Employee_Designation association
  • the selectable options come from the Designation entity
  • the caption shown in the Combo Box is the abbreviation attribute


With this setup, when the page opens in edit mode, Mendix checks the associated Designation object and automatically shows its abbreviation in the Combo Box.


So the recommended setup is:

Your Combo Box should not be linked to the employee code attribute directly.

Instead, it should be linked to the association from Employee to Designation.


Then:

  • Data source = database or microflow returning Designation objects
  • Selectable object = Designation
  • Value = association from Employee to Designation
  • Caption = abbreviation


If your current data model only stores the code in Employee and you cannot change that structure, then you need an extra step before showing the edit page.


In that case, when you retrieve the employee record, do this in a microflow:

  • read the employee code
  • retrieve the matching Designation object where Designation/code = Employee/code
  • set the Employee -> Designation association with that object
  • then open the page


This way, even if the database originally stores only the code, the page will still have the correct associated Designationobject, and the Combo Box can display the abbreviation correctly.


So in practice, the issue is not really with the Combo Box itself. The issue is that the Combo Box needs the related object, while your current logic only provides the code value.


If you want to keep the current model as-is, a helper step in a microflow is needed.

If you want the most maintainable solution, use an association and let the Combo Box work with the Designation object directly.


If this resolves your issue, please mark it as accepted.

answered
0

Dear Amisha,


I understand that you need to display the abbreviation in the dropdown. Most likely, your data in the Combo Box is coming from an association. In your Designation entity, you have both Code and Abbreviation.


Since you are retrieving the Employee using OQL, you already have the Code from the employee record. In the Selectable Objects Microflow, you should filter the records by matching the Employee Code with the Designation Code using XPath, and then return the corresponding Designation list.


In the Combo Box configuration, set the caption attribute to Abbreviation. This will ensure that the abbreviation is displayed in the dropdown.



answered