Hi,
If you want to retrieve Document Type and Document No. from a record within Applied Customer Entries, filtered so that only entries applied to a specific invoice appear. Since both Customer Ledger Entry and Applied Customer Entry derive from the same table (Cust. Ledger Entry), the key lies in using a FlowField with filtered relations.
Let’s break it down:
1. How FlowField works with same-table relationships
In BC, a FlowField can reference the same table if filtered correctly. For Applied Entries:
- Each
Cust. Ledger Entry has related application entries (based on Applies-to ID and Applies-to Doc. No.)
- You can filter the FlowField using the current record’s Entry No. or Document No. to retrieve its corresponding applications
Example FlowField setup:
al
field(50000; "Applied Document No"; Text[20])
{
CalcFormula = Lookup("Cust. Ledger Entry"."Document No." WHERE("Applies-to ID"=FIELD("Applies-to ID")));
FieldClass = FlowField;
}
You can further restrict this with:
al
CalcFormula = Lookup("Cust. Ledger Entry"."Document No."
WHERE("Applies-to ID"=FIELD("Applies-to ID"),
"Document Type"=CONST(Invoice)));
2. How to find which entry relates to the selected invoice
Given a selected invoice (like SI272436 highlighted in your image), you can retrieve applied entries by:
- Filtering
Cust. Ledger Entry where "Applies-to Doc. No." = 'SI272436'
- Or where
"Applies-to ID" equals the Document Entry ID of the invoice
Use this in your page extension or custom page to show only applied entries tied to that invoice.
3. Optional: Use SetAutoCalcFields in AL
If you're building a list page and want applied document numbers to show instantly:
al
CustLedgerEntry.SetAutoCalcFields("Applied Document No");
This lets the system auto-calculate the FlowField as you browse the list.
Helpful references:
Design FlowFields in AL – Microsoft Learn
How Applications Work in BC – Steve Endow
Same Table FlowField Examples – Mibuso
If you find this helpful, feel free to mark this as the suggested or verified answer.
Cheers
Jeffrey