Skip to main content

Notifications

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

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

Posted on by 295

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 ?

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,133 Super User 2024 Season 2 on at
    RE: AL - How to prevent user change field's value after Purchase Order status is Released

    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".

  • Hoang Ng Profile Picture
    Hoang Ng 295 on at
    RE: AL - How to prevent user change field's value after Purchase Order status is Released

    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;

           }

  • Verified answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,133 Super User 2024 Season 2 on at
    RE: AL - How to prevent user change field's value after Purchase Order status is Released

    Separate Error message is not required

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

  • Hoang Ng Profile Picture
    Hoang Ng 295 on at
    RE: AL - How to prevent user change field's value after Purchase Order status is Released

    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;

           }

       }

    }

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,133 Super User 2024 Season 2 on at
    RE: AL - How to prevent user change field's value after Purchase Order status is Released

    Use OnBeforeValidate trigger and standard function TestStatusOpen();

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: AL - How to prevent user change field's value after Purchase Order status is Released

    Hi,

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

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

    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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,056 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans