Hi guys,
I have data entity that currently need to add one field for my enum value, which is the enum label;. Need your help to verify or allocate what is wrong with my syntax, as currently it looks like my enum with value 0 is having empty string.
Here is the code :
public static server str TypeName()
{
TableName viewName = tableStr(MyDeviceDIM);
SysDictEnum dictEnum = new SysDictEnum(enumNum(DeviceType));
int enumIdx;
Map valuesMap = SysComputedColumn::comparisionExpressionMap();
for (enumIdx = 0; enumIdx <= dictEnum.values(); enumIdx )
{
valuesMap.insert(
SysComputedColumn::comparisonLiteral(dictEnum.index2Value(enumIdx)),
SysComputedColumn::returnLiteral(dictEnum.index2Label(enumIdx)));
}
str comparisonField = SysComputedColumn::comparisonField(
viewName,
dataEntityDataSourceStr(MyDeviceDIM, MyDeviceTable),
fieldStr(MyDeviceTable, DeviceType));
return SysComputedColumn::switch(
comparisonField,
valuesMap,
SysComputedColumn::returnLiteral(''));
}
Some information:
MyDeviceDIM is my data entity name, inside the data source is the table name MyDeviceTable and the enum field in that table is DeviceType which having the same name as its enum name.
I only have 2 component in my enum, with value 0 and 1, lets say the label is "label1" and "label2", so currently only those field with value 1 return this new computed column a value of "label2", the other (0) is just an empty string.
Anyone can help me what is wrong with those code ?
Thanks in advance.