Monday, August 28, 2017

Create Field and Field Group in AX 2012 Tables

    TreeNode        treeNode = TreeNode::findNode(@'\\Data Dictionary\Tables\Table1\');
    SysDictClass    sysDictClass = new SysDictClass(treeNode.applObjectId());
    FormRun         formRun = new FormRun(new Args(formStr(AifAction)));
    Form            form = new Form(formStr(AifAction));
    ClassBuild      classBuild;
    SysDictTable    sysDictTable = new SysDictTable(tableNum(table1)); // Maps are treated like tables
    SysDictMethod   sysDictMethod;
    int             i;
    AOTTableFieldList fieldList;
    MemberFunction  method;
    str             methodSource = 'public static str getTime()\n{\n\treturn "3/3/2015";\n}';
    treeNode = sysDictTable.treeNode().AOTfindChild('field Groups').AOTadd('getTime1');
    method = sysDictTable.treeNode().AOTfindChild('field Groups').AOTfindChild('getTime1').AOTadd('mobile');
    method.AOTsave();
    method.AOTsetSource(methodSource, true);
    method.AOTsave();
   
    if (sysDictTable.treeNode().AOTcompile())
    {
        sysDictTable.treeNode().AOTsave();
        info(strFmt("Added"));
    }

No comments:

Post a Comment

Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...