Skip to main content
Post a question

Notifications

Community site session details

Community site session details

Session Id : oG+nv2p/KZWWEI0mGeR/X8
Small and medium business | Business Central, N...
Suggested answer

Posting G/L through AL Code - Error

Like (0) ShareShare
ReportReport
Posted on 24 Apr 2024 03:43:29 by 262
Hi While trying the below code
 
pageextension 50100 CharOfA extends /Chart of Accounts/{    actions    {        addfirst(processing)        {            action(Test)            {                Caption = 'Post something';                ApplicationArea = all;                trigger OnAction()                var                    GLPost: Codeunit /Gen. Jnl.-Post Line/;                    Line: Record /Gen. Journal Line/;                begin                    Line.Init();                    Line./Posting Date/ := TODAY();                    Line./Document Type/ := Line./Document Type/::/ /;                    Line./Document No./ := 'X000004';                    Line./Account Type/ := Line./Account Type/::/G/L Account/;                    Line./Account No./ := '10910';                    Line.Description := 'Youtube Testing';                    Line.Amount := 70;                    // Line./Bal. Account Type/ := LIne./Bal. Account Type/::/G/L Account/;                    // Line./Bal. Account No./ := '10920';                    GLPost.RunWithCheck(Line);                                   end;            }        }    }}
 
I am getting the below 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.

Contact your system administrator.

Tables can be marked as inconsistent during comprehensive tasks, such as posting. This prevents data from being updated incorrectly.

Internal session ID:
1bd5d7c2-6e88-400a-a03a-c81ae7b62dbb

Application Insights session ID:
ff8361cf-b7b3-400e-9aeb-55aeedc41f93

Client activity id:
6d40b9d3-204d-4457-a2ab-e0360a89d034

Time stamp on error:
2024-04-24T03:39:01.5090752Z

User telemetry id:
049e148d-2665-412a-a6d7-bcc1cf3232ac

 

Please help me to resolve. 

  • Dr Gomathi MVP, MCT Community lead, MLE Profile Picture
    262 on 24 Apr 2024 at 11:00:56
    Posting G/L through AL Code - Error
    Thanks for both your suggestions. I tried, but I am getting the same error. I noticed that the error is due to the
    Line."Document No." := 'X000004';
  • Suggested answer
    KasparsSemjonovs Profile Picture
    4,168 Super User 2025 Season 1 on 24 Apr 2024 at 05:57:52
    Posting G/L through AL Code - Error
    CONSISTENT error means that when You are posting DEBIT <> CREDIT, and that causes the error. Check the amounts that You are posting. When creating the journal line, check that the Gen./VAT Posting groups are not filled in. Or if You need them, check that they are ok.
  • Suggested answer
    Saurav.Dhyani Profile Picture
    14,314 Super User 2025 Season 1 on 24 Apr 2024 at 04:16:12
    Posting G/L through AL Code - Error
    Hi,
     
    I think you need to go back and read first before making such attempts.
     
    Here is a tip - When you post any transaction to G/L Entries it needs to adjust. 
     
    Example - If you are showing you earned a profit of $100 a G/L Entry is created but it will also have additional G/L Entries, which explains how its adjusted.
     
     
    Profit $100
    Item Sold -$75
    Delivery -10
    Tax -15
     
    This is what error is explained you that you are only making an entry with 70 and what made that money is not defined. 
     
    Another tip - 
    Create a Journal Entry manually and try posting it to understand how transaction works.
     
    Hope it helps.
     
    Regards,
    Saurav Dhyani

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,485 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,594 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans
Loading complete