Evaluating expression given as a String in X++ [AX 2012]

Executes the specified X++ code that is passed as a string.

anytype runBuf(str job,[anytype param])

Below is the simple example:

void RunBufExample()
{
    str myJob = "int myfunc(int i) {return i+7;}";
    ExecutePermission perm;
    ;
 
    perm = new ExecutePermission();
    if (perm != null)
    {
        perm.assert();  // Assert the use of the dangerous API RunBuf. 
        print runBuf(myJob, 42);
        pause;
        CodeAccessPermission::revertAssert();
    }
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

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