RE: How to hide a field in Business central through page extension
I really appreciate your help.
Below is what I have done for someone who is not a superuser,the fields shouldn't be visible to such user.
I want For Example there 5 users in a tenant and I want only 1 user not to be able to see the "Unit Price","Unit cost" etc but other 4 users should be able to see it.
pageextension 50110 ItemCardExtension extends "Item Card"
{
layout
{
modify("Unit Price")
{
Visible = isSuperUser;
}
modify("Unit Cost")
{
Visible = isSuperUser;
}
modify("Vendor No.")
{
Visible = isSuperUser;
}
// You Can add more fields with same structure
}
var
isSuperUser : boolean;
trigger OnOpenPage();
var
AccessControlRec : Record "Access Control";
begin
isSuperUser := true;
AccessControlRec.reset();
AccessControlRec.setfilter("User Security ID",USERSECURITYID);
AccessControlRec.setfilter("Role ID",'SUPER');
If not AccessControlRec.findset() then
isSuperUser := false;
end;
Thanks in Advance for your help.
Regards,