Table of Contents
INCONSISTENCY ERROR : Cause and Solution
Inconsistency will come both Dynamics NAV or Business Central. However in this post we are explaining how to resolve the same for Navision or Dynamics NAV versions. But if you are have good knowledge of technical can follow similar step and resolve the same over AL language as well.
Cause of Inconsistency Error
INCONSISTENCY Error in Navision Occur because of the following reason.
Posting invoices writes to the G/L entries and the total must ALWAYS be 0.
Somewhere an amount is written but it has no opposite to make the total 0.
This means that there is a problem with some customization of the code.
Solution for Inconsistency Error
This is a trick I use whenever I do try to solve and see why you the db is getting CONSISTENT Error.
I created the following CU. Following solution can used for Dynamics NAV any versions.
OBJECT Codeunit 50000 Single Instance CU
{
OBJECT-PROPERTIES
{
Date=10/11/07;
Time=[ 2:50:02 PM];
Modified=Yes;
Version List=MOD01;
}
PROPERTIES
{
SingleInstance=Yes;
OnRun=BEGIN
IF NOT StoreToTemp THEN BEGIN
StoreToTemp := TRUE;
END ELSE
FORM.RUNMODAL(0,TempGLEntry);
END;
}
CODE
{
VAR
TempGLEntry@1000000000 : TEMPORARY Record 17;
StoreToTemp@1000000001 : Boolean;
PROCEDURE InsertGL@1000000000(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.
}
}
And in CU 12 I add the following Code in function FinishCodeunit
FinishCodeunit()
WITH GenJnlLine DO BEGIN
IF GLEntryTmp.FIND('-') THEN BEGIN
REPEAT
GLEntry := GLEntryTmp;
IF GLSetup."Additional Reporting Currency" = '' THEN BEGIN
GLEntry."Additional-Currency Amount" := 0;
GLEntry."Add.-Currency Debit Amount" := 0;
GLEntry."Add.-Currency Credit Amount" := 0;
END;
GLEntry.INSERT;
//MOD01 Start
SingleCU.InsertGL(GLEntry);
//MOD01 End
IF NOT InsertFAAllocDim(GLEntry."Entry No.") THEN
Once you’ve made the changes. You run the SinleInstanceCU Once.
Then do what ever you do to get the consistency error.
Then Run the SingleInstanceCU again.
You’ll see a list of GL lines. You will see why the transaction is not balanced.
Hope this finds useful for you. If you want similar solution in AL program as well then let me know.