Dynamics Search Engine

Saturday, May 24, 2008

Provide Base Enum name and element number and get the label of that element through X++

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.

1 comment:

  1. Our Website is currently expanding coverage to adult ,LED light up shoes LED shoes for men, adult LED shoes for women, LED dance shoes for boys, LED dance shoes for girls and other categories. Buy the newest LED Shoes with the latest sales & promotions. Find charging led colorful lights fluorescent shoes sports ghost step shoes. All in here - http://www.thewaywholesale.com Can meet all your needs!!!

    ReplyDelete