Enumeration Caption for Export Mapping - Mendix Forum

Enumeration Caption for Export Mapping

4

When mapping an enumeration attribute in an export mapping, it’d be great to have the option to export the caption for that enum value instead of the internal key.

asked
5 answers

Sorry as this answer is quite late but there is a workaround. You can create a new persistent entity which has a 1-1 association with the source entity. Let’s call this entity CaptionHolder and give it one String member called EnumCaption.

In the ExcelTemplate page, change the Enum column from attribute to reference to this CaptionHolder/EnumCaption.

In the export microflow, in the loop where you associate the source entity with the FileDocument, create a new CaptionHolder object and set its EnumCaption <getCaption(sourceEntity/Enum)> and an association with the IteratorObject. Add the newly created CaptionHolder to a list and commit it after the loop.

You can empty CaptionHolder list after the download file node.

Created

@Boris Could you explain more in detail how you do this?

Created

@Joost: I create a JAVAACTION (unfortunately one for every enumeration) that takes the enum_key as input and a locale string and returns the language instance of the caption….

Created

@Joost Sometimes yes. For example when the Caption is a friendly name for a thing, the special character replacement done by the runtime to name the internal keys makes the values harder for the consumer to process. I think it would make sense to have the option to export the caption per enumeration attribute (you’re certainly right that not all enums would make sense to translate) with a “default language” to fall back on if the language is not specified, or even a way to provide the language as an additional request param i.e. &lang=en_US

Created

I guess you currently write a conversion microflow that does this?

If you export the caption, it will change based on the user’s language. Do you want that?

Created