Consistency Error in Dynamics NAV
In Dynamics NAV when you post any transaction to general Ledger, NAV checks and make sure that debits are equal to credits and the total transaction amount is equal to Zero. It has been a while since I have seen the error in NAV, and it’s thanks to Microsoft building automating testing tools and testing their code. I had written a tool on mibuso to help identifying the gl transaction being posted.
In a recent project working with LS Retail, I ran into the issue when posting Statements. LS Retail has solved the issue a different way. What LS Retail has done during posting, that it keeps tracking on the running total and at the end if it does not match zero, it tries to post the entry into rounding GL Account.
The user doesn’t get CONSISTENCY error and the statement gets posted but you still have the unnecessary GL entries and then have to manually move the entries to whatever account it should it.
It’s not a great solution. It’s basically the same thing as moving the dirt under the rug.
While trying to identify the issue, I had to use the Consistency code again to identify the issue.
I have updated the tool using Events in NAV 2016. This way the solution does not modify any objects and can reside in NAV.
Here is the solution.
OBJECT Codeunit 50099 Single Instance CU
{
OBJECT-PROPERTIES
{
Date=09/11/17;
Time=[ 5:18:47 PM];
Modified=Yes;
Version List=MOD01;
}
PROPERTIES
{
SingleInstance=Yes;
OnRun=BEGIN
IF NOT StoreToTemp THEN BEGIN
StoreToTemp := TRUE;
END ELSE
PAGE.RUNMODAL(0,TempGLEntry);
END;
}
CODE
{
VAR
TempGLEntry@1000000000 : TEMPORARY Record 17;
StoreToTemp@1000000001 : Boolean;
[EventSubscriber(Codeunit,12,OnAfterInsertGlobalGLEntry)]
PROCEDURE InsertGL@1000000000(VAR GLEntry@1000000000 : Record 17);
BEGIN
IF StoreToTemp THEN BEGIN
TempGLEntry := GLEntry;
IF NOT TempGLEntry.INSERT THEN BEGIN
TempGLEntry.DELETEALL;
TempGLEntry.INSERT;
END;
END;
END;
BEGIN
END.
}
}
Enjoy.

Like
Report
*This post is locked for comments