3

Dynamics AX 2009 最佳实践加载项在显示方法覆盖上引发以下错误。

"TwC: Validate access to return value from the display/edit method."

这是我的显示方法。

display ABC_StyleName lookupModuleName(ABC_StyleSettings _ABC_StyleSettings)
{
    ;
return ABC_Styles::find(_ABC_StyleSettings.StyleID).StyleName;
}

我假设它希望我在返回结果之前检查配置或安全密钥。关于从哪里开始的任何建议/示例?

谢谢

4

1 回答 1

5

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
于 2009-12-02T22:21:59.910 回答