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...
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,096 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,812 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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 595 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 364 Super User 2026 Season 2

#3
Grigorios Mavrogeorgis Profile Picture

Grigorios Mavrogeorgis 331 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans