web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Dynamically make page fields visible based on the value of another field

(0) ShareShare
ReportReport
Posted on by 3,029

Quick question, why this doesn't work?? No matter how many times I change MyOption field's value, FieldH,V and F are never visible. BC 21.1 environment.

pageextension 50004 "Custom Item card" extends "Item Card"
{
    layout
    {
        addafter(VariantMandatoryDefaultNo)
        {
           
            field(MyOption; Rec.MyOption)  //This is an Option type field in my Item table
            {
                ApplicationArea = Basic, Suite;
            }
            field("FieldH"; Rec."FieldH")
            {
                ApplicationArea = Basic, Suite;
                Visible = Rec.MyOption= Rec.MyOption::"1 Eje"; //Tried with a specific Option value, but still not working
            }
            field("FieldV"; Rec."FieldV")
            {
                ApplicationArea = Basic, Suite;
                Visible = Rec.MyOption> 1;    //This is what I actually need to achieve
            }
            field("FieldF"; Rec."FieldF")
            {
                ApplicationArea = Basic, Suite;
                Visible = Rec.MyOption> 2;
            }
        }
    }
}
Curious fact, Editable = Rec.MyOption> 1; works perfectly, so browser wise, it shouldn't be a problem, as I guess all this has JS on code in the background
I have the same question (0)
  • Mayank Jangid Profile Picture
    60 on at

    Hello Ghetz,

    You need to put all the fields inside the group to which you want to hide or unhide and give visibility property to the group.  

  • Ghetz Profile Picture
    3,029 on at

    Actually visibility conditions are different for each field. If this is the case, I will need to create one group per field. Was wondering if there was any way to avoid that.

  • Mayank Jangid Profile Picture
    60 on at

    Yes, you have to put each and every field in a separate group. Because this is the only way to Dynamically Hide and Unhide the field.

  • Suggested answer
    Nitin Verma Profile Picture
    21,812 Moderator on at

    Hi,

    You can try as per below

    pageextension 50004 "Custom Item card" extends "Item Card"
    {
        layout
        {
            addafter(VariantMandatoryDefaultNo)
            {

                field(MyOption; Rec.MyOption)  //This is an Option type field in my Item table
                {
                    ApplicationArea = Basic, Suite;
                }
                field("FieldH"; Rec."FieldH")
                {
                    ApplicationArea = Basic, Suite;
                    Visible = VisibleControl; //Tried with a specific Option value, but still not working
                }
                field("FieldV"; Rec."FieldV")
                {
                    ApplicationArea = Basic, Suite;
                    Visible = VisibleControl2;    //This is what I actually need to achieve
                }
                field("FieldF"; Rec."FieldF")
                {
                    ApplicationArea = Basic, Suite;
                    Visible = VisibleControl3;
                }
            }
        }

        trigger OnAfterGetRecord()
        begin
            VisibleControl2 := Rec.MyOption > 1;
            VisibleControl := Rec.MyOption = Rec.MyOption::"1 Eje";
            VisibleControl3 :=  Rec.MyOption > 2;
        end;

        var
            VisibleControl: Boolean;
            VisibleControl2: Boolean;
            VisibleControl3: Boolean;
    }
  • Suggested answer
    YUN ZHU Profile Picture
    101,968 Super User 2026 Season 1 on at

    Hi, hope the following helps.

    Dynamic Visibility of Controls (Hide and show fields dynamically)

    https://yzhums.com/14752/

    Thanks.

    ZHU

  • antmas Profile Picture
    60 on at

    ZHU, this post has helped me numerous times, so thanks very much!

  • Suggested answer
    DAnny3211 Profile Picture
    11,423 Super User 2026 Season 1 on at

    Hi

    you must value your control variables in the OnAfterGetRecord() trigger of the page

    DAniele

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,250 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,799 Super User 2026 Season 1

#3
AndrewThomas81 Profile Picture

AndrewThomas81 1,390

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans