web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

inconsistencies in the G/L Entry error on event subscription code unit

(0) ShareShare
ReportReport
Posted on by 3,311

Hi all,

I have created a codeunit based on an event subscriber to update Gen G/L line dimension codes, but receive this error

The transaction cannot be completed because it will cause inconsistencies in the G/L Entry table. Check where and how the CONSISTENT function is used in the transaction to find the reason for the error.

This is the code unit and idea is automatically fill in the dimensions before posting manual journal

    [EventSubscriber(ObjectType::CodeunitCodeunit::"Gen. Jnl.-Post Line", 'OnBeforePostGenJnlLine''', true, true)]
    procedure UpdateDim(var GenJournalLine: Record "Gen. Journal Line");//; Balancing: Boolean
    var
    begin
        if GenJournalLine."Journal Batch Name" = 'DEFAULT' then
            GenJournalLine.SetRange("Journal Template Name", GenJournalLine."Journal Template Name");
            GenJournalLine.SetRange("Line No.", GenJournalLine."Line No.");
            if GenJournalLine.FindFirst() then begin
                if GenJournalLine.get(GenJournalLine."Journal Template Name", GenJournalLine."Line No."then
                    GenJournalLine.Validate("Shortcut Dimension 1 Code", 'A');
                GenJournalLine.Validate("Shortcut Dimension 2 Code", 'B');
                GenJournalLine.Modify(true);
            end;

    end;
I have the same question (0)
  • Suggested answer
    Andy Sather Profile Picture
    Microsoft Employee on at

    Hello  - We currently do not have dedicated Dev support via the Dynamics 365 Business Central forums, but I wanted to provide you some additional resources to assist.  If you need assistance with debugging or coding I would recommend discussing this on one of our communities.

    www.yammer.com/dynamicsnavdev

    dynamicsuser.net/.../developers

    I will open this up to the community in case they have something to add.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,029 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,226 Super User 2026 Season 1

#3
AndrewThomas81 Profile Picture

AndrewThomas81 1,201

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans