---
id: object/codeunit/226
type: object
title: Codeunit 226 "CustEntry-Apply Posted Entries"
summary: Codeunit 226 "CustEntry-Apply Posted Entries" in Base Application (Microsoft.Sales.Receivables). 15 public procedures, 28 events, 1 event subscribers. Present since at least BC23, still in BC30, changed in BC24, BC27.
tier: official
language: en
tags:
  - codeunit
  - base application
versions:
  introduced: null
  last_changed: "27"
  deprecated: null
review:
  state: derived
  by: null
  at: null
  flags: []
generated:
  at: "2026-10-11T00:31:51.816Z"
  pipeline: 0.2.0
  prompts: {}
  input_hash: 4a99cf23427c3eb4a3ec9a383353fde57479eaed1568dff36f0871c95fe01c23
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/Layers/W1/BaseApp/Sales/Receivables/CustEntryApplyPostedEntries.Codeunit.al
    title: src/Layers/W1/BaseApp/Sales/Receivables/CustEntryApplyPostedEntries.Codeunit.al (releases/29.x)
    date: null
    commit: ea08af5ef2d6a9b5c5af4a029288abbe2c883220
    t: null
    quote: null
links:
  learn: []
  objects: []
  features: []
  topics: []
  localizations:
    - localization/au
    - localization/es
    - localization/it
    - localization/nz
    - localization/ru
  videos: []
  posts: []
  guidelines: []
object_type: codeunit
object_id: 226
name: CustEntry-Apply Posted Entries
namespace: Microsoft.Sales.Receivables
app: Base Application
extends: null
first_version: "23"
last_version: "30"
present_in:
  - "23"
  - "24"
  - "25"
  - "26"
  - "27"
  - "28"
  - "29"
  - "30"
changed_in:
  - "24"
  - "27"
source_major: "29"
obsolete: null
countries:
  - au
  - es
  - it
  - nz
  - ru
ms_search_form_ids: []
counts:
  fields: 0
  procedures: 56
  events: 28
  subscribers: 1
relations:
  out: 1
  referenced_by: 0
  pages: 0
  extended_by: 0
  event_subscribers: 0
  calls: 8
  called_by: 5
  implements: 0
---

# Codeunit 226 "CustEntry-Apply Posted Entries"

> Codeunit 226 "CustEntry-Apply Posted Entries" in Base Application (Microsoft.Sales.Receivables). 15 public procedures, 28 events, 1 event subscribers. Present since at least BC23, still in BC30, changed in BC24, BC27.

Base Application · Microsoft.Sales.Receivables · BC23-30 · [source at ea08af5e](https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/Layers/W1/BaseApp/Sales/Receivables/CustEntryApplyPostedEntries.Codeunit.al) · facts from BC29

## Properties

| Property | Value |
|---|---|
| TableNo | Cust. Ledger Entry |
| Permissions | TableData "Cust. Ledger Entry" = rimd |

## Events published

- `OnAfterCheckReversal(CustLedgerEntry: Record "Cust. Ledger Entry")` (integration): Raised after checking if a customer ledger entry is part of a reversal.
- `OnAfterPostApplyCustLedgEntry(GenJournalLine: Record "Gen. Journal Line"; CustLedgerEntry: Record "Cust. Ledger Entry"; var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line")` (integration): Raised after posting the application of a customer ledger entry.
- `OnAfterPostUnapplyCustLedgEntry(GenJournalLine: Record "Gen. Journal Line"; CustLedgerEntry: Record "Cust. Ledger Entry"; DetailedCustLedgEntry: Record "Detailed Cust. Ledg. Entry"; var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line"; var CommitChanges: Boolean; var TempCustLedgerEntry: Record "Cust. Ledger Entry" temporary)` (integration): Raised after posting the unapplication of a customer ledger entry.
- `OnAfterUnApplyCustomer(DtldCustLedgEntry: Record "Detailed Cust. Ledg. Entry")` (integration): Raised after unapplying a customer ledger entry through the UI.
- `OnApplyCustEntryFormEntryOnAfterCheckEntryOpen(ApplyingCustLedgEntry: Record "Cust. Ledger Entry")` (integration): Raised after checking that the entry is open in the apply customer entry form.
- `OnApplyCustEntryFormEntryOnBeforeRunCustEntryEdit(var ApplyingCustLedgEntry: Record "Cust. Ledger Entry")` (integration): Raised before running customer entry edit in the apply customer entry form.
- `OnApplyApplyCustEntryFormEntryOnAfterCustLedgEntrySetFilters(var CustLedgerEntry: Record "Cust. Ledger Entry"; var ApplyingCustLedgerEntry: Record "Cust. Ledger Entry" temporary; var IsHandled: Boolean; var CustEntryApplID: Code[50])` (integration): Raised after filters have been set on customer ledger entries in the apply form.
- `OnBeforeApply(var CustLedgerEntry: Record "Cust. Ledger Entry"; var DocumentNo: Code[20]; var ApplicationDate: Date)` (integration): Raised before applying a customer ledger entry.
- `OnBeforeApplyCustEntryFormEntry(var ApplyingCustLedgEntry: Record "Cust. Ledger Entry"; var IsHandled: Boolean)` (integration): Raised before opening the apply customer entry form.
- `OnBeforeGetApplicationDate(CustLedgEntry: Record "Cust. Ledger Entry"; var ApplicationDate: Date; var IsHandled: Boolean)` (integration): Raised before getting the application date.
- `OnBeforePostApplyCustLedgEntry(var GenJournalLine: Record "Gen. Journal Line"; CustLedgerEntry: Record "Cust. Ledger Entry"; var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line"; ApplyUnapplyParameters: Record "Apply Unapply Parameters")` (integration): Raised before posting the application of a customer ledger entry.
- `OnBeforePostUnapplyCustLedgEntry(var GenJournalLine: Record "Gen. Journal Line"; CustLedgerEntry: Record "Cust. Ledger Entry"; DetailedCustLedgEntry: Record "Detailed Cust. Ledg. Entry"; var GenJnlPostLine: Codeunit "Gen. Jnl.-Post Line"; ApplyUnapplyParameters: Record "Apply Unapply Parameters")` (integration): Raised before posting the unapplication of a customer ledger entry.
- `OnCollectAffectedLedgerEntriesOnAfterSetFilters(var DetailedCustLedgEntry: Record "Detailed Cust. Ledg. Entry"; DetailedCustLedgEntry2: Record "Detailed Cust. Ledg. Entry")` (integration): Raised after filters have been set when collecting affected ledger entries.
- `OnFindLastApplEntryOnAfterSetFilters(var DetailedCustLedgEntry: Record "Detailed Cust. Ledg. Entry")` (integration): Raised after filters have been set when finding the last application entry.
- `OnBeforeCustPostApplyCustLedgEntry(var HideProgressWindow: Boolean; CustLedgEntry: Record "Cust. Ledger Entry"; var IsHandled: Boolean)` (integration): Raised before posting the customer application.
- `OnGetApplicationDateOnAfterSetFilters(var ApplyToCustLedgEntry: Record "Cust. Ledger Entry"; CustLedgEntry: Record "Cust. Ledger Entry")` (integration): Raised after filters have been set when getting the application date.
- `OnBeforeRunUpdateAnalysisView(var IsHandled: Boolean)` (integration): Raised before running the update analysis view.
- `OnBeforeRunCustExchRateAdjustment(var GenJnlLine: Record "Gen. Journal Line"; var TempCustLedgerEntry: Record "Cust. Ledger Entry" temporary; var IsHandled: Boolean)` (integration): Raised before running the customer exchange rate adjustment.
- `OnBeforePostUnApplyCustomerCommit(var HideProgressWindow: Boolean; PreviewMode: Boolean; DetailedCustLedgEntry2: Record "Detailed Cust. Ledg. Entry"; DocNo: Code[20]; PostingDate: Date; CommitChanges: Boolean; var IsHandled: Boolean)` (integration): Raised before posting the unapplication with commit control.
- `OnCheckUnappliedEntriesOnBeforeUnapplyAllEntriesError(DtldCustLedgEntry: Record "Detailed Cust. Ledg. Entry"; LastTransactionNo: Integer; var IsHandled: Boolean)` (integration): Raised before raising the unapply all entries error.
- `OnCustPostApplyCustLedgEntryOnBeforeCommit(var CustLedgerEntry: Record "Cust. Ledger Entry"; var SuppressCommit: Boolean)` (integration): Raised before committing the customer application posting.
- `OnBeforeUnApplyCustomer(DtldCustLedgEntry: Record "Detailed Cust. Ledg. Entry"; var IsHandled: Boolean)` (integration): Raised before unapplying a customer entry through the UI.
- `OnPostUnApplyCustomerCommitOnAfterSetFilters(var DetailedCustLedgEntry: Record "Detailed Cust. Ledg. Entry"; DetailedCustLedgEntry2: Record "Detailed Cust. Ledg. Entry")` (integration): Raised after filters have been set during unapplication posting.
- `OnPostUnApplyCustomerCommitOnAfterGetCustLedgEntry(var CustLedgerEntry: Record "Cust. Ledger Entry")` (integration): Raised after getting the customer ledger entry during unapplication.
- `OnApplyOnBeforePmtTolCust(CustLedgEntry: Record "Cust. Ledger Entry"; var PaymentToleranceMgt: Codeunit "Payment Tolerance Management"; PreviewMode: Boolean; var IsHandled: Boolean)` (integration): Raised before processing payment tolerance during application.
- `OnApplyOnBeforeCustPostApplyCustLedgEntry(CustLedgerEntry: Record "Cust. Ledger Entry"; var ApplyUnapplyParameters: Record "Apply Unapply Parameters")` (integration): Raised before posting the customer ledger entry application.
- `OnPostUnApplyCustomerCommitOnBeforeFilterDtldCustLedgEntry(DetailedCustLedgEntry2: Record "Detailed Cust. Ledg. Entry"; ApplyUnapplyParameters: Record "Apply Unapply Parameters")` (integration): Raised before filtering detailed customer ledger entries during unapplication.
- `OnPostUnApplyCustomerCommitOnAfterPreviewMode(CustLedgerEntry: Record "Cust. Ledger Entry")` (integration): Raised after preview mode processing during unapplication.

## Event subscriptions

- OnRunPreview subscribes to Codeunit "Gen. Jnl.-Post Preview" OnRunPreview

## Procedures

- `Apply(CustLedgEntry: Record "Cust. Ledger Entry"; ApplyUnapplyParameters: Record "Apply Unapply Parameters"): Boolean`: Applies the customer ledger entry based on the specified application parameters.
- `GetApplicationDate(CustLedgEntry: Record "Cust. Ledger Entry"): Date`: Gets the latest posting date among all customer ledger entries with the same Applies-to ID.
- `FindLastApplEntry(CustLedgEntryNo: Integer): Integer`: Finds the last application entry number for the specified customer ledger entry.
- `UnApplyDtldCustLedgEntry(DtldCustLedgEntry: Record "Detailed Cust. Ledg. Entry")`: Unapplies the specified detailed customer ledger entry if it is the last application entry.
- `CheckCustLedgEntryToUnapply(CustLedgEntryNo: Integer; var DetailedCustLedgEntry: Record "Detailed Cust. Ledg. Entry")`: Validates that the customer ledger entry can be unapplied and retrieves the last application entry.
- `UnApplyCustLedgEntry(CustLedgEntryNo: Integer)`: Unapplies the customer ledger entry by its entry number.
- `PostUnApplyCustomer(DtldCustLedgEntry2: Record "Detailed Cust. Ledg. Entry"; ApplyUnapplyParameters: Record "Apply Unapply Parameters")`: Posts the unapplication of a customer ledger entry with automatic commit.
- `PostUnApplyCustomerCommit(DtldCustLedgEntry2: Record "Detailed Cust. Ledg. Entry"; ApplyUnapplyParameters: Record "Apply Unapply Parameters"; CommitChanges: Boolean)`: Posts the unapplication of a customer ledger entry with optional commit control.
- `CheckReversal(CustLedgEntryNo: Integer)`: Checks whether the customer ledger entry is part of a reversal and raises an error if it is.
- `ApplyCustEntryFormEntry(var ApplyingCustLedgEntry: Record "Cust. Ledger Entry")`: Opens the Apply Customer Entries page to allow the user to select entries for application.
- `PreviewApply(CustLedgEntry: Record "Cust. Ledger Entry"; ApplyUnapplyParameters: Record "Apply Unapply Parameters")`: Previews the application of a customer ledger entry without posting.
- `PreviewUnapply(DetailedCustLedgEntry: Record "Detailed Cust. Ledg. Entry"; ApplyUnapplyParameters: Record "Apply Unapply Parameters")`: Previews the unapplication of a detailed customer ledger entry without posting.
- `SetApplyContext(ApplyUnapplyParameters: Record "Apply Unapply Parameters")`: Sets the context for an application preview operation.
- `SetUnapplyContext(var DetailedCustLedgEntry: Record "Detailed Cust. Ledg. Entry"; ApplyUnapplyParameters: Record "Apply Unapply Parameters")`: Sets the context for an unapplication preview operation.
- `GetAppliedCustLedgerEntries(var TempAppliedCustLedgerEntry: Record "Cust. Ledger Entry" temporary; CustLedgerEntryNo: Integer)`: Retrieves all customer ledger entries that have been applied to the specified entry.

Plus 12 local procedures.

## Triggers

OnRun

## Relations

- runs on [Table 21 "Cust. Ledger Entry"](../table/21.md)

## Calls

From the extracted call graph of BC29 (graphify-al on the snapshot checkout): calls whose target is known from a declared type or an `Object::"Name"` argument. Interface dispatch and calls through events are not counted, so the list is not complete.

- [Codeunit 19 "Gen. Jnl.-Post Preview"](../codeunit/19.md) (4 calls: `CustPostApplyCustLedgEntry → ThrowError`, `PostUnApplyCustomerCommit → ThrowError`, `PreviewApply → Preview`, …)
- [Codeunit 11 "Gen. Jnl.-Check Line"](../codeunit/11.md) (2 calls: `CheckPostingDate → DateNotAllowed`, `CheckPostingDate → SetGenJnlBatch`)
- [Codeunit 12 "Gen. Jnl.-Post Line"](../codeunit/12.md) (2 calls: `CustPostApplyCustLedgEntry → CustPostApplyCustLedgEntry`, `PostUnApplyCustomerCommit → UnapplyCustLedgEntry`)
- [Codeunit 426 "Payment Tolerance Management"](../codeunit/426.md) (2 calls: `Apply → PmtTolCust`, `PreviewApply → PmtTolCust`)
- [Codeunit 103 "Cust. Entry-Edit"](../codeunit/103.md) (1 call: `ApplyCustEntryFormEntry → (object)`)
- [Codeunit 410 "Update Analysis View"](../codeunit/410.md) (1 call: `RunUpdateAnalysisView → UpdateAll`)
- [Codeunit 599 "Exch. Rate Adjmt. Run Handler"](../codeunit/599.md) (1 call: `RunCustExchRateAdjustment → RunCustExchRateAdjustment`)
- [Codeunit 9500 "Sequence No. Mgt."](../codeunit/9500.md) (1 call: `OnRun → SetPreviewMode`)

## Called by

- [Codeunit 386 "Reverse Payment Rec. Journal"](../codeunit/386.md) (3 calls: `UnapplyCustomerEntry → CheckCustLedgEntryToUnapply`, `UnapplyCustomerEntry → PostUnApplyCustomer`, `UnapplyCustomerEntry → UnApplyCustLedgEntry`)
- [Page 232 "Apply Customer Entries"](../page/232.md) (3 calls: `PostDirectApplication → Apply`, `PostDirectApplication → GetApplicationDate`, `PostDirectApplication → PreviewApply`)
- [Page 5939 "Serv. Apply Customer Entries"](../page/5939.md) (3 calls: `PostDirectApplication → Apply`, `PostDirectApplication → GetApplicationDate`, `PostDirectApplication → PreviewApply`)
- [Codeunit 1339 "Cancel Posted Sales Cr. Memo"](../codeunit/1339.md) (1 call: `UnapplyEntries → PostUnApplyCustomer`)
- [Codeunit 5280 "SAF-T Data Mgt."](../codeunit/5280.md) (1 call: `GetAppliedSalesDocuments → GetAppliedCustLedgerEntries`)

## Across versions

- Present in: BC23-30
- Changed (declaration) in: BC24, BC27

## Countries that replace it

[AU](../../localizations/au.md), [ES](../../localizations/es.md), [IT](../../localizations/it.md), [NZ](../../localizations/nz.md), [RU](../../localizations/ru.md)

Source: AL metadata extracted from the code (names, ids, signatures, properties); no code bodies (D10).

## Ask your agent

Procedure bodies are not stored here (D10). The call sections above are our own, per object, from the BC29 call graph. For a procedure body or the calls of one procedure, ask bc-code-atlas (external, by Stefan Maron, MIT; default corpus w1-28), which the bc-observatory plugin connects: `bcatlas_resolve_node(object_type: "codeunit", object_name: "CustEntry-Apply Posted Entries")`, then `bcatlas_get_procedure_body` or `bcatlas_get_neighbors` on the returned id.
