This is a reminder that you need to consider whether the user should have access to the data you are returning from the function. For table fields, the kernel normally does this for you based on the security groups the user is in and the security keys set on fields.
To check if a user has access to a field, use the hasFieldAccess
function. To see how this is used, look at the table methods BankAccountStatement.openingBalance()
or CustTable.openInvoiceBalanceMST()
. There are other helper functions to check security keys such as hasMenuItemAccess
, hasSecuritykeyAccess
, and hasTableAccess
.
In your case, add this code:
if(!hasFieldAccess(tablenum(ABC_Styles),fieldnum(ABC_Styles,StyleName)))
{
throw error("@SYS57330");
}
Even after you add that code, you will still get the Best Practice error. To tell the compiler you have addressed the issue, you need to add the following comment immediatly before the function declaration:
//BP Deviation Documented