Free Text Enumerations

3
Hi there, We've got a system that interfaces with numerous systems in our business and vice versa. What I'd like to know is, if we've got an attribute like Title, and in all the external systems, this field is a free text field, but in our Mendix application we would like the users to select from a drop down box like an enumeration for instance, how would we be able to do this. Keep in mind that we need to keep the attribute as a free text (string) field because we won't always be able to map the values from external systems to our enumeration value. Please let me know if I'm unclear about anything. Kind Regards
asked
2 answers
4

If you do not mind using a 'helper' attribute for the selection in the Mendix application, you could do the following:

  • Object with String attribute A and Enumeration helper attribute B.
  • Give the Enumeration in question the proper Captions.
  • Let the users in the Mendix application choose using attribute B, so an enumeration drop down.
  • Add a Before Commit microflow where you write the String version of the enumeration choice in attribute B to the String attribute A, which you use for all purposes but the input in the Mendix application.

Doing the above will require a Java action, since if you'd use toString for this you'd get the enumeration value and not the caption. So what you would need to do in the BCo flow is call the Java action (which has the enumeration as argument) and pass the enumeration value of attribute B. The java action will return the caption of the enumeration as String, so you can then just use a Change activity to write this value to attribute A.

As for the Java action, it should have the following code in the user code area:

// BEGIN USER CODE
if (Enumeration == null){
    return "";
}
return this.Enumeration.getCaption();
// END USER CODE

Where 'Enumeration' should be whatever name you gave to the enumeration argument of the java action.

answered
0

You could map the title to a different entity and then select an object of that entity when selecting a title.

answered