Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Answered

How to make a field uneditable based on an option on the User Setup Page

Posted on by 10

Hello all.

I need some help with the following.

I'm trying to make a field uneditable for some certain users on the Purchase Order. And my process was this, I created a option field Post P.O on the User Setup Table with two options (Confirm and Deny), put it on the User Setup Page.

Then I created a boolean as a global variable on the P.O page, set it in the editable property for the field.

The following code is what I put in the Onaftergetcurrecord trigger

IF UserSetup."Post P.O"=UserSetup."Post P.O"::Confirm THEN Fielditable:=TRUE;

IF UserSetup."Post P.O"=UserSetup."Post P.O"::Deny THEN Fielditable:=FALSE;

Yet it doesn't seem to work if either option is selected on the User Setup Page.

Any help please?

  • Verified answer
    navision begginers Profile Picture
    navision begginers 387 on at
    RE: How to make a field uneditable based on an option on the User Setup Page

    yes of course, you can do same as in purchase line.

    Don't forget to help the community by verifying the answer or at least like the suggestion if it did help in any way. It will let others know that the topic has verified answer and was beneficial to you.

  • Olagoke Agboibon Profile Picture
    Olagoke Agboibon 10 on at
    RE: How to make a field uneditable based on an option on the User Setup Page

    Okay.

    Thank you for your help.

    I do have one more question.

    How about if I wanted to do something similar with a button on the page or the purchase lines?

  • Verified answer
    navision begginers Profile Picture
    navision begginers 387 on at
    RE: How to make a field uneditable based on an option on the User Setup Page

    you don't need to hard code. It will work depend on permission which you have provided in user setup.

  • Verified answer
    RockwithNav Profile Picture
    RockwithNav 6,562 on at
    RE: How to make a field uneditable based on an option on the User Setup Page

    Yes try on On Validate Trigger and cross check how it behaves.

  • Olagoke Agboibon Profile Picture
    Olagoke Agboibon 10 on at
    RE: How to make a field uneditable based on an option on the User Setup Page

    Thank you so much.

    How about if I wanted to use a similar control for the post button?

    Also, doesn't  this line below mean I have to specify the user ID in code?

    usersetup.SETRANGE("User ID", USERID);

  • navision begginers Profile Picture
    navision begginers 387 on at
    RE: How to make a field uneditable based on an option on the User Setup Page

    Dear Olagoke,

    You don't need to write the code on Onaftergetcurrecord trigger. Just write the code on additional field which you have created on PO page.

    Write code on field - OnValidate()  trigger.

    please see my below example code

    'Your New field'- OnValidate()

    usersetup.SETRANGE("User ID", USERID);

    IF usersetup.FINDFIRST THEN BEGIN

     IF usersetup."Your New field"<>TRUE THEN BEGIN

    usersetup.TESTFIELD("Your New field",TRUE);

     ERROR('You do not have permission to change the field')

     END;

    END;

    here usersetup is a variable (table 91)

    I hope it will help you to resolve your query.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans