Hello Community,
I need to make the amount-related fields in the report visible or hidden based on the security role.
So, I have created the Security Role and written code for it. Then, I created a custom field in the InventAgingTmp table to connect the X++ code to the report fields (as a bridge), wrote the security role code, and added the expression to the column visibility expression. One main point is that this project was done by someone else; that is, this project was already existed, and I have just started working from creating the role. The following are the details:
/// <summary>
/// Extension of InventAgingDP class
/// </summary>
[ExtensionOf(classStr(InventAgingDP))]
final class InventoryAgingDP_Extension
{
public InventAgingContract contract;
public InventAgingTmp temp;
public InventAgingTmp tmp;
/// <summary>
/// COC is used for the run method to insert AsonDate value
/// </summary>
protected void run()
{
delete_from temp;
contract = this.parmDataContract();
temp.TPZ_AsOnDate = contract.parmAsOnDate();
temp.TPZ_ReportingCur = contract.parmreportingCur();
next run();
}
//My code
public static boolean hasAmountRole()
{
SecurityRole securityRole;
SecurityUserRole securityUserRole;
select firstonly Name from securityRole
exists join securityUserRole
where securityRole.RecId == securityUserRole.SecurityRole
&& (securityRole.Name == 'InventAgingValueFieldsRole'
|| securityRole.Name == "Current User")
&& securityUserRole.User == curUserId();
return securityUserRole.RecId != 0;
}
}
[ExtensionOf(tableStr(InventAgingTmp))]
final class InventAgingTmp_Extension
{
public void insert()
{
this.ShowAmount = InventAgingDP::hasAmountRole() ? NoYes::Yes : NoYes::No;
next insert();
}
}
The expression used in the column visibility property - show or hide based on the expression is:
=IIF(Fields!TPZ_ShowAmountLabel.Value = 1, false, true)
The actual problem is that if I add this expression, either I add the role to the user or not the column gets hidden. Where, when the role is assigned the columns should be Visible. So, may I know what is the reason the field is not getting visible?

Report
All responses (
Answers (