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.