How to hide messages in Sales Documents while validating Shipment Date

Hide – “Shipment Date xx/xx/xx is before work date xx/xx/xx” note

Sales Order:

Build a Sales Order and validate the Shipment Date with a too-early date of workdate.

step1
Here, the Workdate is 09/12/2023 and I put on a timely Shipment Date i.e. 09/05/2023.

*** The proof/monitory message will be shown only when an item is validated in the Sales Line, not while Shipment Date validation.

Validation Dialog when the Shipment Date is earlier than the Workdate.

step2

I attempt with the My Business Central setup page.

Go to Business Central Web Client -> click on Setup

step3

step4

step5

Snap-on modified when I collected notifications and explored for Workdate prompt. Turn off the allowed button and try again.

step6

Sales Method

Sales System – with Shipment Date too early than Workdate.

step7

Smooth acquired the message – Shipment Date 09/05/23 is before workdate 09/12/23.

step8

Allow dig into the language now.

In Sales underline, I explored with – before the work date and set up the under label Text014.

step9

Text014: Label ‘%1 %2 is before work date %3’;

Search with – Text014 in Sales underLine and you can notice that Text014 is used in an event named “CheckShipmentDateBeforeWorkDate”

step10

local procedure CheckShipmentDateBeforeWorkDate()
var
IsHandled: Boolean;
begin
IsHandled := false;
OnBeforeCheckShipmentDateBeforeWorkDate(Rec, xRec, HasBeenShown, IsHandled);
if IsHandled then
exit;
if ("Shipment Date"< WorkDate()) and HasTypeToFillMandatoryFields() then
if not (GetHideValidationDialog() or HasBeenShown) and GuiAllowed then begin
Message(
Text014,
FieldCaption("Shipment Date"), "Shipment Date", WorkDate());
HasBeenShown := true;
end;
end;

So the core process to hide the message is the “GetHideValidationDialog” function

step11
If we can set HideValidationDialog as true, we can pass over the message here. Let’s find the method!

Adept is a procedure to set the value of HideValidationDialog called “SetHideValidationDialog”

step12

procedure SetHideValidationDialog(NewHideValidationDialog: Boolean)
begin
HideValidationDialog := NewHideValidationDialog;
OnAfterSetHideValidationDialog(Rec, NewHideValidationDialog);
end;

We are required to set the value as true before the Shipment date is validated and so the preferred utilizes the OnBeforeValidate activate of Shipment Date control to hide this dialog.

step13

tableextension 50001 "SalesLineExt" extends "Sales Line"
{
fields
{
modify("Shipment Date")
{
trigger OnBeforeValidate()
begin
Rec.SetHideValidationDialog(true);
end;
}
}
}

If HideValidationDialog is true –

step14

we can at present pass over the message statement –

“Shipment Date 09/05/23 is prior to work date 09/12/23.”

step15

Conclusion

Ultimately, the best approach depends on your specific needs and context. Weigh the risks and benefits carefully before choosing to hide validation messages in Business Central services.

Remember, prioritizing transparency with customers is crucial in most situations. Consider alternative communication channels to inform them of any concerns regarding the shipment date without cluttering the sales document.

 

 

Read more on related Insights