If you are running native SQL statements in Ax, you might see below error while executing code.
Request for the permission of type ‘SqlStatementExecutePermission’ failed.
(C)JobsRahAddressImport – line 76
sqlQ = “Select * From CustTable”;
// Set code access permission to help protect the use of
perm = new SqlStatementExecutePermission(sqlQ);
perm.assert();//should run on server
// BP deviation documented
rs = cmd.executeQuery(sqlQ);//will throw error
This only means that your code is running on client side. You must call the assert method in your code on the same tier, usually the server tier, that the corresponding CodeAccessPermission::demand method is called on before the protected API is executed. Call a method on the server tier from one of the following:
- A server static method
- A class instance method that is set to run on the server by using the RunOn class property
Feel free to post any comment / feedback here.