runBuf Function
Dynamics AX 4.0
Executes X++ code that is passed as a string.
anytype runBuf(str job,[anytype param])
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. Ensure that the user has development privileges by setting the security key to SysDevelopment on the control that calls this function.
The following example calls runBuf 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.
// BP deviation documented.
print runBuf(myJob, 42);
pause;
CodeAccessPermission::revertAssert();
}
}
Community Additions
ADD
Show: