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

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

I want to hide based on condition

(0) ShareShare
ReportReport
Posted on by 90

I am trying to show/hide field based in condition. I created field in user setup ( show Unit Price ) and in the page I created variable used it onOpenPage and give it the value of  Show unit Price ( from user setup ) 

this is the code 

pageextension 60115 "Sales Order Subform Ext" extends "Sales Order Subform"
{
layout
{
modify("Unit Price"){
Visible= ShowHideUnitPrice;
}

trigger OnOpenPage()
var
UserSetup: record "User Setup";
begin
Usersetup.get(Userid);
ShowHideUnitPrice:=UserSetup.ShowUnitPirce;

end;

var
ShowHideUnitPrice: Boolean;
}

but it is not working , can someone tell me any other way to do this 

I have the same question (0)
  • Suggested answer
    Vaishnavi J Profile Picture
    3,062 on at

    Hi,

    Write your trigger in this way

    trigger OnOpenPage()

    var

    UserSetup: record "User Setup";

    begin

    clear (UserSetup);

    UserSetup.reset();

    UserSetup.SetRange("User ID", UserId);

    UserSetup.SetRange(UNitPrice, true);
            if UserSetup.findfirst() then
                ShowHideUnitPrice := true
            else
                ShowHideUnitPrice := false;

    If my answer was helpful to you, please verify it so that other users know it worked. Thank you very much

  • Suggested answer
    Arjun Anand Profile Picture
    202 on at

    Hi,

    Field Visible Boolean will not remove the column from the page properly as it will remain present in the choose column list.

    Thanks  

  • muaz deyab Profile Picture
    90 on at

    I tried this but it did not work as well

  • muaz deyab Profile Picture
    90 on at

    I Just want to hide from the subform , Users will not use personalization

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

    Hi,

    Please change your code with below

    pageextension 60115 "Sales Order Subform Ext" extends "Sales Order Subform"

    {

       layout

       {

           modify("Unit Price")

           {

               Visible = ShowHideUnitPrice;

               ShowCaption = false;

           }

       }

       trigger OnOpenPage()

       var

           UserSetup: record "User Setup";

       begin

           Usersetup.get(Userid);

           ShowHideUnitPrice := UserSetup.ShowUnitPirce;

       end;

       var

           [InDataSet]

           ShowHideUnitPrice: Boolean;

    }

  • muaz deyab Profile Picture
    90 on at

    it worked thanks

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,126

#2
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 744 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 674 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans