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

Notifications

Announcements

No record found.

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,255

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
    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,362

#2
YUN ZHU Profile Picture

YUN ZHU 867 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 607

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans