How to hide messages in Purchase Documents while validating Order Date

Hide – “Order Date xx/xx/xx is earlier than the work date xx/xx/xx” message

Purchase Order:

Create a Purchase Order and validate the Order Date with an earlier date of workdate.

Create a Purchase Order

In this case, the workdate is 09/12/2023 and I add an earlier Order Date i.e. 09/11/2023.

*** The validation/warning message will be shown only when an item is validated in the Purchase Line, not during Order Date validation.

Validation Dialog when Order Date is earlier than the work date.

Validation Dialog
I tried with My BC settings page.

Go to BC Web Client -> click on Settings

BC Web Client

BC Settings







BC Setting1
Click on Change when I receive notifications and search for Workdate Reminder. Turn off the Enabled button and try again.

receive notifications

Purchase Order – with Order Date earlier than Workdate.
Purchase order
Still got the message –

got message

Let’s dig into the code now.

In Purchase Line, I searched with – earlier than the work date and found the below label Text018.

label Text018

Text018: Label ‘%1 %2 is earlier than the work date %3.’;

Search with – Text018 in the Purchase Line and you can see that Text018 is used in a function named “ShowEarlyOrderDateMessage”
Search with

local procedure ShowEarlyOrderDateMessage()
ShowMessage: Boolean;
ShowMessage := not (HideValidationDialog or HasBeenShown) and GuiAllowed;
OnShowEarlyOrderDateMessageOnAfterCalcShowMessage(Rec, ShowMessage);
if ShowMessage then begin
Message(Text018, FieldCaption("Order Date"), "Order Date", WorkDate());
HasBeenShown := true;

“ShowEarlyOrderDateMessage()” is called from the Order Date OnValidate trigger of the Purchase Line.

field label

So the key procedure to hide the message is “ShowEarlyOrderDateMessage()”

There are two ways to Hide/Ignore the validation message.
validation message

  • We can subscribe to the event before the message and then just set Showmessage as False.
  • To use Hidevalidation Dialog as it is a protected variable.

Subscribing event “OnShowEarlyOrderDateMessageOnAfterCalcShowMessage”
codeunit 50101 EventSubscriberManagement
[EventSubscriber(ObjectType::Table, Database::"Purchase Line", OnShowEarlyOrderDateMessageOnAfterCalcShowMessage, '', false, false)]
local procedure OnShowEarlyOrderDateMessageOnAfterCalcShowMessage(PurchaseLine: Record "Purchase Line"; var ShowMessage: Boolean);
ShowMessage := false;

Using HideValidationDialog

Protected variable:

Protected variables are variables that you can access from a dependent extension. It has only any effect on the extension object. Only a global variable can be accessed from an extension if it is under the Protected Var segment.

Here, we have HideValidationDialog which is a protected variable and can be extended in a table extension.
table extension
TableExtension to access variable HideValidationDialog.
15 img
tableextension 50100 PurchaseLineExt extends "Purchase Line"
modify("Order Date")
trigger OnBeforeValidate()
HideValidationDialog := true;

If HideValidationDialog is true or ShowMessage is false –
we can now ignore the message saying –

Order Date xx/xx/xx is earlier than the work date xx/xx/xx

work date


In Microsoft Dynamics 365 Business Central, you can use validation rules and triggers to hide messages in purchase documents based on specific conditions, such as the order date. Below are general steps that you can follow to achieve this. Please note that the exact steps may vary based on your specific version of Business Central.

Please note that the actual field names and events may vary based on your specific Business Central version and customization setup. Ensure you refer to the documentation for your version and consider consulting with your system administrator or Business Central developer for assistance.


Read more on related Insights