Skip to main content

Notifications

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 2,869

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;
  • Suggested answer
    Andy Sather Profile Picture
    on at
    RE: inconsistencies in the G/L Entry error on event subscription code unit

    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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

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

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 1,200

#2
YUN ZHU Profile Picture

YUN ZHU 1,006 Super User 2025 Season 1

#3
Mansi Soni Profile Picture

Mansi Soni 864

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans