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

Payment Journal - automatically populate external document number

(6) ShareShare
ReportReport
Posted on by 39
Hi All,
 
I asked a question previously regarding having the External Document number auto populated in the payment journal. It is understood that Business Central does not automatically populate the external document no, but it is possible through automated customization or an extension.
 
Can anyone point me in the direction of how I can automate this customisation or what the extension is that I am looking for so that I can get this actioned.
 
The previous answer I received explained " However, this can be automated through a small customization or extension. The customization would copy the External Document No. from the applied invoice to the Payment Journal Line’s External Document No. field during the application process"
 
Sorry to bring up the same topic, but I actually need further information so I can take the appropriate steps to implement this customization / extension.
 
Thank you.
 
I have the same question (0)
  • Verified answer
    JUBEL THOMAS JOY Profile Picture
    279 on at
    Hi,
     
    To implement this, you’ll need to create a Business Central extension using AL language. Here's a simplified outline of what the extension should do:
    1. Event Subscriber
    Create an event subscriber to hook into the logic when a payment journal line is created or modified during the application of vendor entries.
    2. Fetch External Document No.
    From the applied vendor ledger entry (invoice), retrieve the External Document No..
    3. Update Payment Journal Line
    Set the External Document No. field on the payment journal line with the value retrieved.
     
    Kindly review and test using following code. If you are not aware about coding always recommended to take guidance from any technical.
     
    sample code as follows

    [EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Line", 'OnBeforePostGenJnlLine', '', true, true)]
    procedure OnBeforePostGenJnlLine(var GenJournalLine: Record "Gen. Journal Line"; var IsHandled: Boolean)
    var
        VendorLedgerEntry: Record "Vendor Ledger Entry";
    begin
        if GenJournalLine."Document Type" = GenJournalLine."Document Type"::Payment then begin
            VendorLedgerEntry.SetRange("Applies-to ID", GenJournalLine."Applies-to ID");
            if VendorLedgerEntry.FindFirst() then begin
                GenJournalLine."External Document No." := VendorLedgerEntry."External Document No.";
            end;
        end;
    end;
     
  • Gerardo Rentería García Profile Picture
    27,052 Most Valuable Professional on at
    Hi
    You can use development to obtain this value and copy it to the journal, but be careful when applying multiple invoices to a single payment line; you must define what you want (for example, use the number of the first invoice, concatenate them, or leave the field empty).
    Best
    Gr
  • Suggested answer
    Jainam M. Kothari Profile Picture
    16,773 Super User 2026 Season 1 on at
    Hello,
     
    The System does not automatically populate the External Document No. in the Payment Journal when applying vendor entries, but this can be automated through a small customization or extension.
     
  • Suggested answer
    Sohail Ahmed Profile Picture
    11,177 Super User 2026 Season 1 on at
    To automate the population of the External Document No. in the Payment Journal, you'd need a small AL extension that copies this value from the applied invoice when you apply it in the journal. Here's a short overview of how you can implement it:
     
     
    ---
     
    🔧 Basic Customization Steps (AL Extension):
     
    1. Event Subscriber: Create a subscriber to the OnAfterApplyCustLedgEntry event (or similar event depending on where you apply the invoice in the Payment Journal).
     
     
    2. Logic: In the subscriber, fetch the External Document No. from the applied Customer Ledger Entry (usually type = Invoice), and update the current Gen. Journal Line.External Document No. with that value.
     
     
    3. Deployment: Package this as a .app file using Ctrl+Shift+B in Visual Studio Code and publish it to your environment.
     
     
     
     
    ---
     
    Example Snippet:
     
    [EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Line", 'OnAfterApplyCustLedgEntry', '', true, true)]
    local procedure CopyExternalDocNo(GenJournalLine: Record "Gen. Journal Line"; CustLedgEntry: Record "Cust. Ledger Entry")
    var
        GenJnlLine: Record "Gen. Journal Line";
    begin
        if GenJournalLine."External Document No." = '' then begin
            GenJnlLine.Get(GenJournalLine."Journal Template Name", GenJournalLine."Journal Batch Name", GenJournalLine."Line No.");
            GenJnlLine."External Document No." := CustLedgEntry."External Document No.";
            GenJnlLine.Modify();
        end;
    end;
     
     
    ---
     
    You can share this requirement with your developer or partner if you're not writing the code yourself.
     
    ✅ Mark this answer as verified if it helps you.
     
     

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,382 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,625 Super User 2026 Season 1

#3
AndrewThomas81 Profile Picture

AndrewThomas81 1,376

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans