Some one may need to use codes to create or edit a method in Axapta.
Here is an example to show how to create a lookup method for a form's field in runtime.
static void CreateFieldMethod(Args _args)
{
TreeNode tn1,tnAddr, methodsNode;
MemberFunction memberFunction;
str source;
;
//it is really good to use Verbatim String as well.
//The reason why I use escape characters here is
//because this line of code is copied from standard Axapta application :)
tn1 = infolog.findNode(
"\\Forms\\Address\\Data Sources\\Address\\Fields\\AddrRecId");
tnAddr = infolog.findNode( "\\Forms\\Address" );
methodsNode = tn1.AOTfindChild( 'Methods' );
methodsNode.AOTadd('lookup');
memberFunction = methodsNode.AOTfindChild( 'lookup' );
source = @"public void lookup(FormControl _formControl, str _filterStr)
{
super(_formControl, _filterStr);
}" ;
memberFunction.AOTsetSource(source, false);
memberFunction.AOTsave();
methodsNode.AOTsave();
tnAddr.AOTcompile();
}
Subscribe to:
Post Comments (Atom)
How to identify the user that was used to change an object from AOT in AX2012
Get the object name for which we need to track these (user and date&time) information's. Login to SQL Server Management Studio an...
-
Combo boxes in Dialogs are added by adding a DialogField object with the type of an enum. The enum is then controlling what items you can pi...
-
This article explains: How to picking list through a job using X++ in Dynamics AX. Applied on: Dynamics AX 2009 SP1 Create a job a...
-
A while ago I had the need to translate labels, I was creating eMail bodys while using SysMailer and wanted to use different languages for d...
No comments:
Post a Comment