Write comments to existing tablemethod through X++ code?


If you are able to retrieve method name, you can get methods content as well.
Below you can find my short example how you can do that:
TreeNode    tableNode = SysDictTable::newTableId(tableNum(tableName)).treeNode();
   TreeNode    newMethodNode;
   str         source;
   newMethodNode = tableNode.AOTfindChild('Methods').AOTfindChild('methodName');
   source = newMethodNode.AOTgetSource();
   info(source);
   /*
   source = this.addSomeLogicHere(comment);
   */
   newMethodNode.AOTsetSource(source, true);
   newMethodNode.AOTcompile();
   newMethodNode.AOTsave();
   tableNode.AOTsave();

My idea is to work with method content as with string - just incorporate comment adding logic.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.