In this article you will be aware that how the get the label of an element of a base enum.
Prerequisite: You should have basic programming knowledge of X++.
I applied it on Ax 3.0
You can provide the base enum name directly using global method fieldnum() or you can provide it in a string using method fieldname2id() where you need to give table id and fieldname.
Steps are as below:
1) Open your Ax application then AOT.
2) Go to Jobs node and create a new job. Rename the job if you need. I renamed it to DictEnumElementLabel.
3) Now write the following lines...
static void DictEnumElementLabel(Args _args)
{
DictEnum de;
DictField df;
;
df = new DictField(tablenum(SalesTable),fieldname2id(tablenum(SalesTable),'SalesType'));
if(typeof(df.type()) == Types::Enum) //checks if Type == Enum
{
de = new DictEnum(df.enumId());
info(de.index2Name(3)); // print element label
}
else
info('Not Enum type');
}
4) Now run the job and you will get the label of element of the base enum 'SalesTypes' you specified.
No comments:
Post a Comment