web
You’re offline. This is a read only version of the page.
close
Skip to main content
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,011

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
    RE: Dynamically make page fields visible based on the value of another field

    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,011 on at
    RE: Dynamically make page fields visible based on the value of another field

    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
    RE: Dynamically make page fields visible based on the value of another field

    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,684 Moderator on at
    RE: Dynamically make page fields visible based on the value of another field

    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
    92,762 Super User 2025 Season 2 on at
    RE: Dynamically make page fields visible based on the value of another field

    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
    RE: Dynamically make page fields visible based on the value of another field

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

  • Suggested answer
    DAnny3211 Profile Picture
    11,376 on at
    RE: Dynamically make page fields visible based on the value of another field

    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 4,327

#2
Sumit Singh Profile Picture

Sumit Singh 2,734

#3
Nimsara Jayathilaka. Profile Picture

Nimsara Jayathilaka. 2,599

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans