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

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

(0) ShareShare
ReportReport
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?

I have the same question (0)
  • navision begginers Profile Picture
    387 on at

    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.

  • Olagoke Agboibon Profile Picture
    10 on at

    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);

  • Suggested answer
    RockwithNav Profile Picture
    8,637 Super User 2025 Season 2 on at

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

  • Verified answer
    navision begginers Profile Picture
    387 on at

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

  • Olagoke Agboibon Profile Picture
    10 on at

    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
    387 on at

    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.

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,238

#2
YUN ZHU Profile Picture

YUN ZHU 773 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 630

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans