Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

Disabling a page

(0) ShareShare
ReportReport
Posted on by 194

Hello All,

Right now, am trying to Disable a page if the user changed the Status as "Completed", then it should disable for all the users except one User group. If the status was completed, then if any of the users enter to the particular page, it should display who has changed the status and when it was completed.

Now, first part i was completed. Means while changing the Status the page is disabling, But the issue facing is

a)  lines of items and Header menus are not disabled for that particular page and if we click on next and coming back at that time sometimes its not disabling.

b) Name and time Label of the status changed was not getting. 

Kindly requesting your valuable suggestion which i will get desired output

8004.jobss.jpg

pageextension 62001 "Jobs PageDisable" extends "Job Card"
{

    trigger OnOpenPage();
    var

        UserGroupMember: Record "User Group Member";
    begin

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

    trigger OnValidate();
    var
        myInt: Integer;
        Confirm: Label 'The Job No :%1  Has been Closed by the User : %2 On Date %3.';
    begin
        If Rec.Completed then begin
            IF not UserGroupMember.Get('ADMIN', UserSecurityId(), CompanyName) then begin
                If Dialog.Confirm(StrSubstNo(Confirm,Rec."No.", Rec.SystemModifiedBy, Rec."Last Date Modified"), false) then begin
                    CurrPage.Update();
                end

            end;
        end;



}

  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 75,802 Super User 2024 Season 2 on at
    RE: Disabling a page

    Hi, Just a little suggestion, hope this helps you.

    Regarding a, Menu cannot be Disabled, so you can prevent the user from opening this page in the program, but the disadvantage is that the user cannot confirm the page data in the case of Completed. If you have specific actions you don't want the user to run, you need to add control code to OnBeforeAction trigger of the menu.

    As for Next and Coming Back, please try adding the control code to the OnNextRecord (Page) Trigger.

    pastedimage1655857156001v1.png

    Regarding b, there is no OnValidate() in the trigger of the page, I'm not sure how you got it to compile.

    pastedimage1655857500340v2.png

    pastedimage1655857521357v3.png

    PS: If you want to determine whether the user is a Super user, you can refer to the following method.

    https://yzhums.com/25886/

    Hope this helps.

    Thanks.

    ZHU

  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 993 Super User 2024 Season 1 on at
    RE: Disabling a page

    I think you should try to solve this using a security filter instead.

    You can read more about how they work here:

    docs.microsoft.com/.../security-filters

  • Suggested answer
    Marco Mels Profile Picture
    Marco Mels on at
    RE: Disabling a page

    Hello,

    We currently do not have dedicated Dev support via the Dynamics 365 Business Central forums, but I wanted to provide you some additional resources to assist. If you need assistance with debugging or coding I would recommend discussing this on one of our communities.

    www.yammer.com/dynamicsnavdev

    www.dynamicsuser.net/.../14

    I will open this up to the community in case they have something to add.

    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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,703 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,433 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans