Home > X++ stuffs > How to insert a codeSnippet during runTime.

How to insert a codeSnippet during runTime.

Adding a piece of code of at runtime is now easier in AX and this could be achieved by using a Tree Node.

Please refer the below example as to how a code can be inserted @ the runtime.

 

static void InsertionofCodeSnippet(Args _args)

{

    TreeNode    treeNode;

    int              i;

    str              actualCode;

    //Code that needs to be inserted.

    actualCode = @"int active()

{

    int ret;

    ;

    ret = super();

    element.setBOMRouteEnabled();

    element.setRFIDEnabled();

    element.setItemDimEnabled();

    element.pbAsetEnabled();

    element.setFiscalLIFOEnabled();

    info(strfmt(inventTable.caption()));

    return ret;

}"

    ;

    #AOT

    //Find the destination as to where it needs to be added

    treeNode = infolog.findNode(‘\\Forms\\InventTable\\Data Sources\\InventTable\\Methods\\active’);

    //Set the source.

    treeNode.AOTsetSource(actualCode, false);

    treeNode = infolog.findNode(‘\\Forms\\InventTable’);

    //Load it in the AOT

    treeNode.AOTload();

    treeNode.AOTsave();

    treeNode.AOTrefresh();

}

 
 
Advertisements
Categories: X++ stuffs
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: