Question: How to
get values of base enums using code in
x++
Scenario- 1: static
void
getEnumValues(Args _args)
{
EnumId enumId = enumNum(LedgerDimensionType);
DictEnum dictEnum = new DictEnum(enumId);
int count = dictEnum.values();
int counter
for(counter = 0; counter < count; counter ++)
{
// You can use the number of method
exposed by DictEnum class
//
dictEnum.name(counter)
// dictEnum.index2Value(counter)
//
dictEnum.index2Symbol(counter)
//
dictEnum.index2Label(counter)
}
}
Scenario- 2: Retrieve Label from Enum Value
The follow codes is useful due to retrieve the label of TransType field related table InventTrans :
1. SysDictEnum dictEnum = new SysDictEnum( enumnum(InventTransType) );
2. dictEnum.value2Label(InventTrans.TransType)
1. SysDictEnum dictEnum = new SysDictEnum( enumnum(InventTransType) );
2. dictEnum.value2Label(InventTrans.TransType)
Scenario- 3: How can I make this comparison language independent?
I'm not sure of getting list of all languages. But you can try below code, it
may help in your case.
static void Enum2Label(Args _args)
{
DictEnum dictEnum;
int valueIndex;
LanguageId languageId='fr';
int enumId=enumNum(ItemType);
str labelId;
;
dictEnum = new DictEnum(enumId);
if (dictEnum)
{
for (valueIndex = 0 ; valueIndex < dictEnum.values(); valueIndex++)
{
labelId = dictEnum.index2LabelId(valueIndex);
info(SysLabel::labelId2String2(labelId, languageId));
}
}
}
Happy DAXing.....
{
DictEnum dictEnum;
int valueIndex;
LanguageId languageId='fr';
int enumId=enumNum(ItemType);
str labelId;
;
dictEnum = new DictEnum(enumId);
if (dictEnum)
{
for (valueIndex = 0 ; valueIndex < dictEnum.values(); valueIndex++)
{
labelId = dictEnum.index2LabelId(valueIndex);
info(SysLabel::labelId2String2(labelId, languageId));
}
}
}
Happy DAXing.....
No comments:
Post a Comment