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

AL - How to prevent user change field's value after Purchase Order status is Released

(0) ShareShare
ReportReport
Posted on by 297

After Purchase Order is released, some fields cannot be changed but some fields are allowed to change. EX: Transaction Type

pastedimage1673592665904v1.png

How to customize to show the error when User tries to change this field value while the Purchase Order status is released ?

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

    Hi,

    You can customize the solution OnBeforeValidate of this field and put below code

    Rec.Testfield(Status,rec.Status::Open);

    Thanks.

  • Suggested answer
    Mohana Yadav Profile Picture
    60,993 Super User 2025 Season 2 on at

    Use OnBeforeValidate trigger and standard function TestStatusOpen();

  • Hoang Ng Profile Picture
    297 on at

    Thanks Nitin, Yadav

    Is it the below code correct:

    tableextension 50110 "TLC Purchase Hdr. Ext" extends "Purchase Header"

    {

       fields

       {

           // Add changes to table fields here

           field(50110; "Deposit Date"; Date)

           {

               Caption = 'Deposit Date';

               DataClassification = CustomerContent;

           }

           modify("Transaction Type")

           {

               trigger OnBeforeValidate()

               begin

                   Rec.Testfield(Status,rec.Status::Open);

                   error('You can not change this field after PO is released');

               end;

           }

       }

    }

  • Verified answer
    Mohana Yadav Profile Picture
    60,993 Super User 2025 Season 2 on at

    Separate Error message is not required

    Just Rec.Testfield(Status,rec.Status::Open); is enough or TestStatusOpen();

  • Hoang Ng Profile Picture
    297 on at

    Thanks Yadav.

    Your way can work.

    I tried another way to show the detail message

    modify("Transaction Type")

           {

               trigger OnBeforeValidate()

               begin

                   if (rec.Status = rec.Status::Released) then begin

                       //Rec.Testfield(Status, rec.Status::Open);

                       error('You can not change this field after PO is released');

                   end;

               end;

           }

  • Suggested answer
    Mohana Yadav Profile Picture
    60,993 Super User 2025 Season 2 on at

    Just make sure that if you are using other purchase documents like Invoice or Return Order etc. and transaction type field then also the error message will show as "PO is released".

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