Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Service | Customer Service, Contact Center, Fie...
Unanswered

Customizing PO Posting in Business Central to Use External Table for Amount and Dimensions

(0) ShareShare
ReportReport
Posted on by

Dear All,

I am working on a customization in Business Central where I want the posting routine for Purchase Orders (POs) to derive the amounts and dimensions for the General Ledger Entries from a custom table that I have linked to the Purchase Lines.

This custom table contains the following fields:

  • DocumentNo

  • LineNo

  • Amount (split into sublines in percentages summing to 100%)

  • Dimension1

  • Dimension2

  • Dimension3

  • Dimension4

  • Dimension5

Each subline entry includes its own dimension values across Dimension1 to Dimension5.

Requirement:
During PO posting, instead of using the default Purchase Line amount and dimensions, the system should read and use the split amounts and their corresponding dimensions from this custom subline table.

I want also the Preview Posting to work as native way so that I can see whether the entries behave as I want in this requirement.

I have attempted to subscribe to relevant events in the standard codeunits to achieve this customization, but so far, I have not been successful.

I would greatly appreciate any guidance or suggestions on how to approach this. Specifically:

  • Which events or codeunits would be best to extend or override or subscribe to?

  • what is the best way to do it?

  • If this is not possible how can I customize my independent posting routine especially that will make item ledger entries and others to be affected. At least General journal line has GL account and Fixed asset Account Types but no Item

  • Suggested answer
    Muhammad Shahzad Shafique Profile Picture
    553 Most Valuable Professional on at
    Customizing PO Posting in Business Central to Use External Table for Amount and Dimensions
    1. Subscribe to OnBeforePostGLAcc or similar in Gen. Jnl.-Post Line (Codeunit 12)
    • Here, you can replace the default amount and dimensions using your custom logic.
    al
    [EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Line", 'OnBeforePostGLAcc', '', true, true)]
    local procedure OverrideGLPosting(var GenJnlLine: Record "Gen. Journal Line"; var IsHandled: Boolean)
    var
        CustomSplit: Record "Your Custom Subline Table";
    begin
        if CustomSplit.Get(GenJnlLine."Document No.", GenJnlLine."Line No.") then begin
            // Loop through split lines
            repeat
                // Create new journal line for each subline
                GenJnlLine."Amount" := CustomSplit.Amount;
                GenJnlLine."Shortcut Dimension 1 Code" := CustomSplit.Dimension1;
                GenJnlLine."Shortcut Dimension 2 Code" := CustomSplit.Dimension2;
                ...
                // Optionally call posting routine manually
            until CustomSplit.Next() = 0;
           
            IsHandled := true; // prevent default
        end;
    end;

    2. Ensure Split Logic Hooks into Preview Posting
    To work with Preview Posting, you also need to handle:
    • Codeunit 19 – Gen. Jnl.-Show Ledger
    • Codeunit 1001 – Purch.-Post + Print (for orchestration)
    • Possibly extend GetGLEntries in Codeunit 12 or mirror the logic in a simulation routine
    Use event OnBeforeInsertGLEntry in Codeunit 12 to modify each GL Entry before insertion (supports preview).
    3. Handling Item Ledger Entries (If Needed)
    Modifying ILEs is not directly supported via general journals — for that:
    • You’d need to simulate or call routines in Codeunit 22 – Item Jnl.-Post Line
    • Not recommended unless you're duplicating the entire item posting logic
    Only split and modify G/L entries and dimensions; leave item posting to standard.
     

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

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

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

Leaderboard > Service | Customer Service, Contact Center, Field Service, Guides

#1
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 51 Most Valuable Professional

#2
Ramesh Kumar Profile Picture

Ramesh Kumar 42

#3
David Shaw_UK Profile Picture

David Shaw_UK 27

Featured topics

Product updates

Dynamics 365 release plans