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...
Suggested Answer

How to Disable one Page

(0) ShareShare
ReportReport
Posted on by 224

Hello All,

how can we disable/Lock the page to restrict from Edit/Delete, Means in Job Page, there is Status icon to change the status. once if the user has changed the status as "Complete" then only designated user should only have the option to Reopen it again

Is it possible ? how we can make it

jobss.jpg

Regards

I have the same question (0)
  • Suggested answer
    Nitin Verma Profile Picture
    21,698 Moderator on at

    Hi,

    Yes we can achieve that by creating a new Boolean field in User setup table, name can be "Edit Job".

    and then create a eventsubscriber like below, you have to create below code in one of the custom Codeunit

    This is one of the way to achieve

       [EventSubscriber(ObjectType::Page, page::"Job Card", 'OnModifyRecordEvent', '', true, true)]

       local procedure CheckJobCardEditabe(var Rec: Record Job)

       var

           UserSetup: Record "User Setup";

       begin

           if rec.IsTemporary then

               exit;

           UserSetup.get(UserId);

           if not UserSetup."Edit Job" then

               Error('You dont have permission to edit the Job.');

       end;

  • Suggested answer
    Vaishnavi J Profile Picture
    3,062 on at

    Hi,

    If you don't want to go for Customization then simply go to user which should not allow to modify check its permission sets and then create copy of that permission sets using copy action in permission sets page.

    And in the copied permission sets add Security filter like below in Table Date 167 Job 

    pastedimage1654068345907v2.png

    Once you have completed the security filter then go to user again and remove the old permission sets and replace with your new copied one.

    Please note if the user has super permission then it will override the security filter defined in your new copied permission sets.

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

  • Suggested answer
    Tabrez Ajaz Profile Picture
    785 on at

    Hi LearnBC,

    Both Vaishnavi Joshi and Nitin Verma provided good solution.

    As the solution provided by Vaishnavi Joshi is very efficient but you need to do the mentioned changes every time for different environments.

    And the solution provided by Nitin Verma will work every time if you include this in your already available extension.

  • LearnBC Profile Picture
    224 on at

    Thanks Nithin for the Response.

    In the above attached Screenshot, that is the "icon" for changing to Complete. (But in code where it is mentioned) and

    Once its changed to complete (any user Can change the status to completed )..Only User Group "ADMIN" members can only should have the option for reopen it again for all.

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

    Yes in that case please assign the below code. Who has that boolen true against their user Id only that user can open it again.

     

     [EventSubscriber(ObjectType::Page, page::"Job Card", 'OnModifyRecordEvent', '', true, true)]

        local procedure CheckJobCardEditabe(var Rec: Record Job)

        var

            UserSetup: Record "User Setup";

        begin

            if rec.IsTemporary then
                exit;
            UserSetup.get(UserId);
            if not Completed then
                if not UserSetup."Edit Job" then
                    Error('You dont have permission to edit the Job.');

        end;
  • Suggested answer
    YUN ZHU Profile Picture
    95,329 Super User 2025 Season 2 on at

    Hi, Here are two very simple examples that hopefully will give you some hints as well.

    https://yzhums.com/25886/

    https://yzhums.com/9132/

    Thanks.

    ZHU

  • LearnBC Profile Picture
    224 on at

    Thanks for all the Valuable responses.

    Right now in the Job page, i already brought 4 fields(Prv Cost,Prv Invoice,Exp etc), on those fields once user enters the data and once they confirmed it then It cannot be editable for all the users except one User. - That part is working perfect as expected

    On same Page Extension, am trying to add , Once any of the User changed the status as Completed, then It cannot be EDIT/Delete for all Users,(all job Page-Header/Details Should Disable)  Only User group "JOB" Members can only have the option for Reopen the Page again for all.

    pageextension 60018 jobcardExt extends "Job Card"
    {
        layout
        {
            modify("Starting Date")
            {
                ShowMandatory = true;
            }
            modify("Ending Date")
            {
                ShowMandatory = true;
            }
            modify(Completed)
            {
                trigger OnAfterValidate()
                begin
                    CheckCompleted();
                    CurrPage.Update(true);
                end;
            }

            addafter("Project Manager")
            {
                field("Previous Year Cost"; Rec."Previous Year Cost")
                {
                    ApplicationArea = all;
                    Editable = IsEditable;
                    ToolTip = 'Specifies the Prev Yr Cost & Cannot be Editable once Enter and Confirm the value';
                    Caption = 'Previous Year Cost';

                    trigger OnValidate()
                    var
                        myInt: Integer;
                        Confirm: Label 'You have added a Prev Yr Cost Amount %1 for the Job %2. It should not be editable once confirmed';
                    begin
                        If Rec."Previous Year Cost" <> 0.00 then begin
                            If not (UserId = 'ANUSUYA') then begin
                                If Dialog.Confirm(StrSubstNo(Confirm, Rec."Previous Year Cost", Rec."No."), false) then begin
                                    CheckEditable();
                                    CurrPage.Update();
                                end else
                                    Rec."Previous Year Cost" := 0.00;
                            end;
                        end;
                    end;
                }

            }
            addafter("Previous Year Cost")
            {
                field("Previous Year Invoice"; Rec."Previous Year Invoice")
                {
                    ApplicationArea = all;
                    ToolTip = 'Specifies the Prev Yr Inv  & Cannot be Editable once Enter and Confirm the value';
                    Editable = IsEditablePrvInv;

                    Caption = 'Previous Year Invoice';

                    trigger OnValidate()
                    var
                        myInt: Integer;
                        Confirm: Label 'You have added a Prev Yr Inv Amount %1 for the Job %2. It should not be editable once confirmed';
                    begin
                        If Rec."Previous Year Invoice" <> 0.00 then begin
                            If not (UserId = 'ANUSUYA') then begin
                                If Dialog.Confirm(StrSubstNo(Confirm, Rec."Previous Year Invoice", Rec."No."), false) then begin
                                    CheckEditable();
                                    CurrPage.Update();
                                end else
                                    Rec."Previous Year Invoice" := 0.00;
                            end;
                        end;
                    end;
                }

            }
            addafter("Previous Year Invoice")
            {

                field("Project Cost"; Rec."Project Cost")
                {
                    ApplicationArea = all;
                    ToolTip = 'Specifies the Proj Cost & Cannot be Editable once Enter and Confirm the value';
                    Editable = IsEditablePrvCost;
                    Caption = 'Project Revenue';

                    trigger OnValidate()
                    var
                        myInt: Integer;
                        Confirm: Label 'You have added a Cost Amount %1 for the Job %2. It should not be editable once confirmed';
                    begin
                        If Rec."Project Cost" <> 0.00 then begin
                            If not (UserId = 'ANUSUYA') then begin
                                If Dialog.Confirm(StrSubstNo(Confirm, Rec."Project Cost", Rec."No."), false) then begin
                                    CheckEditable();
                                    CurrPage.Update();
                                end else
                                    Rec."Project Cost" := 0.00;
                            end;
                        end;
                    end;
                }

            }
            addafter("Project Cost")
            {
                field("Project Expense"; Rec."Project Expense")
                {
                    ApplicationArea = all;
                    ToolTip = 'Specifies the Proj Exp & Cannot be Editable once Enter and Confirm the value';
                    Editable = IsEditablePrjExp;


                    trigger OnValidate()
                    var
                        myInt: Integer;
                        Confirm: Label 'You have added a Expense Amount %1 for the Job %2. It should not be editable once confirmed';
                    begin
                        If Rec."Project Expense" <> 0.00 then begin
                            If not (UserId = 'ANUSUYA') then begin
                                If Dialog.Confirm(StrSubstNo(Confirm, Rec."Project Expense", Rec."No."), false) then begin
                                    CheckEditable();
                                    CurrPage.Update();
                                end else
                                    Rec."Project Expense" := 0.00;
                            end;
                        end;
                    end;
                }

            }

        }
    /*CODE FOR ABOVE 4 FIELDS ARE NOT EDITABLE ONCE THEY CONFIRMED, ONLY ONE PERSON CAN EDIT*/
        var
            [InDataset]
            IsEditable: Boolean;
            IsEditablePrvInv: Boolean;
            IsEditablePrvCost: Boolean;
            IsEditablePrjExp: Boolean;

        local procedure CheckEditable()
        var
            UserRec: Record "User Group Member";
        begin
            If Rec."Previous Year Cost" <> 0 then begin
                If UserId = 'ANUSUYA' then
                    IsEditable := true
                else
                    IsEditable := false;
            end else
                IsEditable := true;

            If Rec."Previous Year Invoice" <> 0 then begin
                If UserId = 'ANUSUYA' then
                    IsEditablePrvInv := true
                else
                    IsEditablePrvInv := false;
            end else
                IsEditablePrvInv := true;

            If Rec."Project Cost" <> 0 then begin
                If UserId = 'ANUSUYA' then
                    IsEditablePrvCost := true
                else
                    IsEditablePrvCost := false;
            end else
                IsEditablePrvCost := true;


            If Rec."Project Expense" <> 0 then begin
                If UserId = 'ANUSUYA' then
                    IsEditablePrjExp := true
                else
                    IsEditablePrjExp := false;
            end else
                IsEditablePrjExp := true;
        end;

    /* Code for Disable the Page- Only User group (Job)members should have edit option*/
        local procedure CheckCompleted()
        var
            UserGroupMember: Record "User Group Member";
        begin

            If Rec.Completed then begin
                IF not UserGroupMember.Get('JOB', UserSecurityId(), CompanyName) then begin
                    CurrPage.Editable := false;
                end
                else
                    CurrPage.Editable := true;
            end;

        end;

        trigger OnAfterGetCurrRecord()
        begin
            var
                myInt: Integer;
                //CheckCompleted();
                CheckEditable()

        end;

        trigger OnOpenPage()
        begin
            var
                myInt: Integer;
                // CheckCompleted();
                CheckEditable();
        end;

        trigger OnAfterGetRecord()
        begin
            var
                myInt: Integer;
                // CheckCompleted();
                CheckEditable();

        end;
    /* Code for Making Fieldsd Mandatory */

        trigger OnClosePage()
        begin
            //CheckCompleted();
            If Rec."Starting Date" = 0D then
                Error('Error');
        end;

        trigger OnQueryClosePage(CloseAction: Action): Boolean
        var
            myInt: Integer;
        begin
            If Rec."Starting Date" = 0D then begin
                Error('Please enter the Starting date');
                // CloseAction := CloseAction::Cancel;
            end;
            If Rec."Ending Date" = 0D then begin
                Error('Please enter the Ending date');
                //CloseAction := CloseAction::Cancel;
            end;

        end;


    }
  • LearnBC Profile Picture
    224 on at

    Hello All,

    pls request you all to correct where am doing mistake in this AL Code

    Regards

  • LearnBC Profile Picture
    224 on at

    Hello 

    i already done half of the portion like this. kindly request you help me to understand where i made the mistake on this pls

    pageextension 60018 jobcardExt extends "Job Card"
    {
        layout
        {
            modify("Starting Date")
            {
                ShowMandatory = true;
            }
            modify("Ending Date")
            {
                ShowMandatory = true;
            }
            modify(Completed)
            {
                trigger OnAfterValidate()
                begin
                    CheckCompleted();
                    CurrPage.Update(true);
                end;
            }

            addafter("Project Manager")
            {
                field("Previous Year Cost"; Rec."Previous Year Cost")
                {
                    ApplicationArea = all;
                    Editable = IsEditable;
                    ToolTip = 'Specifies the Prev Yr Cost & Cannot be Editable once Enter and Confirm the value';
                    Caption = 'Previous Year Cost';

                    trigger OnValidate()
                    var
                        myInt: Integer;
                        Confirm: Label 'You have added a Prev Yr Cost Amount %1 for the Job %2. It should not be editable once confirmed';
                    begin
                        If Rec."Previous Year Cost" <> 0.00 then begin
                            If not (UserId = 'ANUSUYA') then begin
                                If Dialog.Confirm(StrSubstNo(Confirm, Rec."Previous Year Cost", Rec."No."), false) then begin
                                    CheckEditable();
                                    CurrPage.Update();
                                end else
                                    Rec."Previous Year Cost" := 0.00;
                            end;
                        end;
                    end;
                }

            }
            addafter("Previous Year Cost")
            {
                field("Previous Year Invoice"; Rec."Previous Year Invoice")
                {
                    ApplicationArea = all;
                    ToolTip = 'Specifies the Prev Yr Inv  & Cannot be Editable once Enter and Confirm the value';
                    Editable = IsEditablePrvInv;

                    Caption = 'Previous Year Invoice';

                    trigger OnValidate()
                    var
                        myInt: Integer;
                        Confirm: Label 'You have added a Prev Yr Inv Amount %1 for the Job %2. It should not be editable once confirmed';
                    begin
                        If Rec."Previous Year Invoice" <> 0.00 then begin
                            If not (UserId = 'ANUSUYA') then begin
                                If Dialog.Confirm(StrSubstNo(Confirm, Rec."Previous Year Invoice", Rec."No."), false) then begin
                                    CheckEditable();
                                    CurrPage.Update();
                                end else
                                    Rec."Previous Year Invoice" := 0.00;
                            end;
                        end;
                    end;
                }

            }
            addafter("Previous Year Invoice")
            {

                field("Project Cost"; Rec."Project Cost")
                {
                    ApplicationArea = all;
                    ToolTip = 'Specifies the Proj Cost & Cannot be Editable once Enter and Confirm the value';
                    Editable = IsEditablePrvCost;
                    Caption = 'Project Revenue';

                    trigger OnValidate()
                    var
                        myInt: Integer;
                        Confirm: Label 'You have added a Cost Amount %1 for the Job %2. It should not be editable once confirmed';
                    begin
                        If Rec."Project Cost" <> 0.00 then begin
                            If not (UserId = 'ANUSUYA') then begin
                                If Dialog.Confirm(StrSubstNo(Confirm, Rec."Project Cost", Rec."No."), false) then begin
                                    CheckEditable();
                                    CurrPage.Update();
                                end else
                                    Rec."Project Cost" := 0.00;
                            end;
                        end;
                    end;
                }

            }
            addafter("Project Cost")
            {
                field("Project Expense"; Rec."Project Expense")
                {
                    ApplicationArea = all;
                    ToolTip = 'Specifies the Proj Exp & Cannot be Editable once Enter and Confirm the value';
                    Editable = IsEditablePrjExp;


                    trigger OnValidate()
                    var
                        myInt: Integer;
                        Confirm: Label 'You have added a Expense Amount %1 for the Job %2. It should not be editable once confirmed';
                    begin
                        If Rec."Project Expense" <> 0.00 then begin
                            If not (UserId = 'ANUSUYA') then begin
                                If Dialog.Confirm(StrSubstNo(Confirm, Rec."Project Expense", Rec."No."), false) then begin
                                    CheckEditable();
                                    CurrPage.Update();
                                end else
                                    Rec."Project Expense" := 0.00;
                            end;
                        end;
                    end;
                }

            }

        }
    /*CODE FOR ABOVE 4 FIELDS ARE NOT EDITABLE ONCE THEY CONFIRMED, ONLY ONE PERSON CAN EDIT*/
        var
            [InDataset]
            IsEditable: Boolean;
            IsEditablePrvInv: Boolean;
            IsEditablePrvCost: Boolean;
            IsEditablePrjExp: Boolean;

        local procedure CheckEditable()
        var
            UserRec: Record "User Group Member";
        begin
            If Rec."Previous Year Cost" <> 0 then begin
                If UserId = 'ANUSUYA' then
                    IsEditable := true
                else
                    IsEditable := false;
            end else
                IsEditable := true;

            If Rec."Previous Year Invoice" <> 0 then begin
                If UserId = 'ANUSUYA' then
                    IsEditablePrvInv := true
                else
                    IsEditablePrvInv := false;
            end else
                IsEditablePrvInv := true;

            If Rec."Project Cost" <> 0 then begin
                If UserId = 'ANUSUYA' then
                    IsEditablePrvCost := true
                else
                    IsEditablePrvCost := false;
            end else
                IsEditablePrvCost := true;


            If Rec."Project Expense" <> 0 then begin
                If UserId = 'ANUSUYA' then
                    IsEditablePrjExp := true
                else
                    IsEditablePrjExp := false;
            end else
                IsEditablePrjExp := true;
        end;

    /* Code for Disable the Page- Only User group (Job)members should have edit option*/
        local procedure CheckCompleted()
        var
            UserGroupMember: Record "User Group Member";
        begin

            If Rec.Completed then begin
                IF not UserGroupMember.Get('JOB', UserSecurityId(), CompanyName) then begin
                    CurrPage.Editable := false;
                end
                else
                    CurrPage.Editable := true;
            end;

        end;

        trigger OnAfterGetCurrRecord()
        begin
            var
                myInt: Integer;
                //CheckCompleted();
                CheckEditable()

        end;

        trigger OnOpenPage()
        begin
            var
                myInt: Integer;
                // CheckCompleted();
                CheckEditable();
        end;

        trigger OnAfterGetRecord()
        begin
            var
                myInt: Integer;
                // CheckCompleted();
                CheckEditable();

        end;
    /* Code for Making Fieldsd Mandatory */

        trigger OnClosePage()
        begin
            //CheckCompleted();
            If Rec."Starting Date" = 0D then
                Error('Error');
        end;

        trigger OnQueryClosePage(CloseAction: Action): Boolean
        var
            myInt: Integer;
        begin
            If Rec."Starting Date" = 0D then begin
                Error('Please enter the Starting date');
                // CloseAction := CloseAction::Cancel;
            end;
            If Rec."Ending Date" = 0D then begin
                Error('Please enter the Ending date');
                //CloseAction := CloseAction::Cancel;
            end;

        end;


    }

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 3,226

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 2,047 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,257 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans