In the sales process NAV check for both credit limits and overdue balance on the customer. This is a needed process to inform the salesperson before posting the order or the invoice. However, the problem is that the warning is displayed every time the salesperson creates or modifies a sales line.

When a salesperson has agreed to sell this customer why should we continue to give him warnings that he has already approved?
I solved this by creating a new table to log warnings. If a salesperson opts to continue the sales process despite the warning an entry is created in the log table. Next time the system checks for a warning it will read the log table to see if a warning of that type has already been given to that salesperson.
The changes needed to implement this are minimal.
In Form and Page 343
- move the local variable ExitValue from the ShowWarning function to Globals.
- Add a code to the ShowWarning function to set ExitValue to zero before the warning logic.
- Add a global function GetExitValue of type integer that will return the value of ExitValue
Then add functions to Codeunit 312 to check for log entry and to create a new log entry.
[code]
SalesHeaderCheck(SalesHeader : Record "Sales Header")
IF CustCheckCreditLimit.SalesHeaderShowWarning(SalesHeader) THEN BEGIN
//#01-
IF ExistsInWarningLog(
SalesHeader."Document Type",
SalesHeader."No.",
SalesHeader."Bill-to Customer No.",
CustCheckCreditLimit.GetExitValue) THEN EXIT;
//#01+
OK := CustCheckCreditLimit.RUNMODAL = ACTION::Yes;
//#01-
IF OK THEN BEGIN
AddToWarningLog(
SalesHeader."Document Type",
SalesHeader."No.",
SalesHeader."Bill-to Customer No.",
SalesHeader."Sell-to Customer No.",
SalesHeader."Posting Date",
CustCheckCreditLimit.GetExitValue);
CLEAR(CustCheckCreditLimit);
END ELSE
// IF NOT OK THEN
//#01+
ERROR(Text000);
END;[/code]
[code]
#01-()
ExistsInWarningLog(DocumentType : Option;DocumentNo : Code[20];BillToCustomerNo : Code[20];WarningType : Integer) : Boolean
WITH WarningLog DO BEGIN
SETCURRENTKEY("Document Type","No.","Bill-to Customer No.","Warning Type","User ID");
SETRANGE("Document Type",DocumentType);
SETRANGE("No.",DocumentNo);
SETRANGE("Bill-to Customer No.",BillToCustomerNo);
SETRANGE("Warning Type",WarningType);
SETRANGE("User ID",USERID);
EXIT(NOT ISEMPTY);
END;
AddToWarningLog(DocumentType : Option;DocumentNo : Code[20];BillToCustomerNo : Code[20];SellToCustomerNo : Code[20];PostingDate : Date;
WITH WarningLog DO BEGIN
INIT;
"Entry No." := 0;
"Date and Time" := CURRENTDATETIME;
"Bill-to Customer No." := BillToCustomerNo;
"Document Type" := DocumentType;
"Sell-to Customer No." := SellToCustomerNo;
"No." := DocumentNo;
"Warning Type" := WarningType;
"Posting Date" := PostingDate;
"User ID" := USERID;
INSERT;
END;
#01+()
[/code]
I created a new role with read permission to the warning table and assigned that role to administrative users. I added indirect read and indirect add to a general role that gives a sales person permission to create a sales invoice.
Warning Log Objects