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.
(S)ClassesSqlStatementExecutePermissiondemand
(S)ClassesStatementexecuteQuery
(C)JobsRahAddressImport – line 76
Code snippet you might be using:
sqlQ = “Select * From CustTable”;
// Set code access permission to help protect the use of
// Statement.executeUpdate.
perm = new SqlStatementExecutePermission(sqlQ);
perm.assert();//should run on server
try
{
// BP deviation documented
rs = cmd.executeQuery(sqlQ);//will throw error
while (rs.next())
{
//process records
}
}
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
-or-
- 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.