Field value in Data entity

Hi all,

I have a mapped field in a custom entity. The requirement is: for any value received take the related value eg. if 10 is imported then set the value to TEST1. I wanted to understand what would be the best approach ie via switch, macro, enum. Also how should I implement it since in macro if I write #define.TEST1(10) then I will also need to write #deine.10("TEST1) as such for around 20 fields and also enum does not allow for specific value. Adding such comparison in switch will result in lot of hard coding.

Also in which method should I place this since I want this transformation to happen only in case of import operation & not export.

Forget macros; there aren’t many reasons for using them and this isn’t one of them.

First of all, thing again if you want to hard-code these values. Shouldn’t you use a configuration table instead?

If it should be hard-coded, using a Map object.

You can do that in mapEntityToDataSource().