Controlling Field Visibility on Master Pages Using User Setup in Business Central

Reading Time: 3 minutes

If there’s one requirement that comes up in almost every manufacturing or distribution project I do, it’s this: the client wants their users to be able to create and edit master data freely, but they absolutely do not want the shop floor or junior staff seeing sensitive financial numbers. I’m talking about bank balances, G/L net changes, unit costs, and profitability figures.

The first instinct is always to look at standard permission sets. The problem is that standard permissions are a blunt instrument. If you remove read access to a table, the user gets an error and can’t do their job. If you leave it open, they see everything on the page.

To solve this, I always rely on a very specific, scalable AL pattern: extending the User Setup table and driving page visibility through a central codeunit. Here is how I actually build it in the real world.

The Setup: Giving Admins Control

Field Visibility via User Setup
Field Visibility via User Setup

First, we need a place to store these rules. I extend the standard User Setup table and add a few specific Boolean fields. Things like “Can See G/L Balances”, “Can See Bank Balances”, or “Can See Unit Costs”.

I also extend the User Setup page so the administrators have a clear “Field Visibility” group where they can just tick or untick these boxes for each user.

The Engine: One Codeunit to Rule Them All

This is a critical best practice: never write visibility logic directly inside your page extensions. If the client changes their mind later, you don’t want to go hunting through 15 different page extensions.

I create a single codeunit called Visibility Management. Every rule lives here. It looks something like this:

codeunit 50100 "Visibility Management"
{
    procedure CanSeeGLBalances(): Boolean
    var
        UserSetup: Record "User Setup";
    begin
        if not UserSetup.Get(UserId) then
            exit(false);  // Always default to hidden if the record is missing

        exit(UserSetup."Can See G/L Balances");
    end;
}

The AL Implementation: How to Actually Hide the Fields

If you learned to code back in the old NAV (C/AL) days, you might be tempted to just write CurrPage."Net Change".Visible := false;. If you try that in modern Business Central AL, the compiler will just laugh at you. You can’t dynamically change the visibility property directly in code like that anymore.

Instead, in modern AL, you tie the field’s Visible property to a global Boolean variable in your page extension, and you evaluate that variable when the page opens.

Here is what the actual page extension for the G/L Account Card looks like:

pageextension 50100 "GL Account Card Ext" extends "G/L Account Card"
{
    layout
    {
        modify("Net Change")
        {
            Visible = ShowFinancials;
        }
        // Don't forget to hide the FactBoxes too!
        modify("G/L Account Balance")
        {
            Visible = ShowFinancials;
        }
    }

    trigger OnOpenPage()
    var
        VisMgt: Codeunit "Visibility Management";
    begin
        ShowFinancials := VisMgt.CanSeeGLBalances();
    end;

    var
        ShowFinancials: Boolean;
}

You use this exact same pattern across your Item Cards, Bank Account Cards, and even General Journals if you need to hide running balances.

The Big Security Warning

I always have to explain this to my clients in Greece and the UK: this pattern is a UI trick, not a vault. It controls what the user sees on that specific screen. It does not secure the data at the SQL or table level.

If a user knows how to use “Open in Excel”, writes an API query, or has access to financial reports, they will still see the numbers. You must always combine this UI visibility trick with proper, restrictive permission sets, especially using indirect permissions on ledger entries, so they can post their work without having direct read access to the general ledger.

This pattern has saved me a lot of headaches over the years. It gives management the strict visual control they want, while keeping the system open and easy to use for the people actually doing the work on the floor.


Discover more from Inside Business Central

Subscribe to get the latest posts sent to your email.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top