runBuf Function

Applies To: Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012

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

anytype runBuf(str job,[anytype param])

Parameters

Parameter

Description

job

The string that contains the code to run.

param

The parameters for the code being passed to the function; optional.

Return Value

The return value of the code that was passed to the function; otherwise 0 if the code has no return value.

Remarks

If an attacker can control input to the runBuf function, a security risk exists. Therefore, this function runs under Code Access Security. Calls to this function on the server require permission from the ExecutePermission Class.

Example

The following example calls this method to run the contents of the supplied buffer. When this code is run, the integer 49 is sent to the print window.

    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();
        }
    }

Announcements: To see known issues and recent fixes, use Issue search in Microsoft Dynamics Lifecycle Services (LCS).