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.
Microsoft Dynamics AX, AIF, X++, MorphX, Sharepoint, SSRS, Biztalk Server, .Net, Integration, Enterprise Portal
Dynamics Search Engine
Saturday, May 24, 2008
Provide Base Enum name and get the number of elements through X++
In this article I will tell you how the get number of elements 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.
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 DictEnumElements.
3) Now write the following lines...
static void DictEnumElements(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(int2str(de.values()));
}
else
info('Not Enum type');
}
4) Now run the job and you will get the number of elements of the base enum 'SalesTypes'
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.
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 DictEnumElements.
3) Now write the following lines...
static void DictEnumElements(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(int2str(de.values()));
}
else
info('Not Enum type');
}
4) Now run the job and you will get the number of elements of the base enum 'SalesTypes'
Thursday, May 15, 2008
How to browse tables in Dynamics Ax by using X++
This article explains:
How to browse a table runtime in Microsoft Dynamics Ax
How to rbowse a table using x++ language in Microsoft Dynamics Ax
How to browse a table programatically in Microsoft Dynamics Ax
How to open a Microsoft Dynamics Ax table by using X++ codes
Note: You should be familiar with Dynamics Ax basic programming.
{
SysTableBrowser systabB;
;
systabB = new SysTableBrowser();
systabB.run(tablenum(inventtable));
}
How to browse a table runtime in Microsoft Dynamics Ax
How to rbowse a table using x++ language in Microsoft Dynamics Ax
How to browse a table programatically in Microsoft Dynamics Ax
How to open a Microsoft Dynamics Ax table by using X++ codes
Note: You should be familiar with Dynamics Ax basic programming.
Open your Ax application then AOT.
Go to Jobs node and crate a new job.
Copy and paste the code below. Here I renamed the job to BrowseTable.
I applied it on Ax 3.0
static void BrowseTable(Args _args){
SysTableBrowser systabB;
;
systabB = new SysTableBrowser();
systabB.run(tablenum(inventtable));
}
Subscribe to:
Posts (Atom)