with X++ Jobs Created field method on datasource in AX Form

Created field method on datasource in AX Form_其他Created field method on datasource in AX Form_其他_02代码
static void Jimmy_CreateFieldMethodOnDataSource(Args _args)
{
TreeNode tn1,tnAddr, methodsNode;
MemberFunction memberFunction;
str source;
System.Exception clrException;
;
try
{
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);//true is Static method
memberFunction.AOTsave();
methodsNode.AOTsave();
tnAddr.AOTcompile();
}
catch( Exception::Error)
{
throw exceptionTextFallThrough();
}
catch( Exception::CLRError)
{
clrException
= CLRInterop::getLastException();
if (clrException != null)
{
clrException
= clrException.get_InnerException();
if (clrException != null)
{
error(clrException.get_Message());
}
}
}
info(
"Created method successful!" + methodsNode.treeNodePath());
}
/*
Thanks for Max Belugin's comments,
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 :)
*/