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

Announcements

No record found.

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,023

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,023 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,794 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
    99,090 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,417 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,949 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,064 Super User 2026 Season 1

#3
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 559 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans