I want to prevent users for generating Sales Invoice for Customers having overdue balance AND where Due Date + 30D < Today's Date.
Hence, the following code was written in Table 36 Sales Header under the trigger Sell-To Customer No - OnValidae:
IF "Document Type" = "Document Type"::Invoice THEN BEGIN
CustLedgEntry.SETCURRENTKEY("Customer No.", Open, "Due Date");
CustLedgEntry.GET("Bill-to Customer No.");
DueDate:= CALCDATE('<30D>', CustLedgEntry."Due Date");
IF (CustLedgEntry.Open = CustLedgEntry.Open::"1") AND
(DueDate < TODAY())
THEN
ERROR('Customer has Overdue amount')
END;
However, I'm getting the following error when adding a customer with overdue balance in Sales Invoice:
Can anyone inform what was wrong on the code. Thanks
*This post is locked for comments