---
id: object/codeunit/5813
type: object
title: Codeunit 5813 "Undo Purchase Receipt Line"
summary: Codeunit 5813 "Undo Purchase Receipt Line" in Base Application (Microsoft.Purchases.History). 5 public procedures, 31 events, 1 event subscribers. Present since at least BC23, still in BC30, changed in BC24-28.
tier: official
language: en
tags:
  - codeunit
  - base application
versions:
  introduced: null
  last_changed: "28"
  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: 6ab79421dfd9839855a74b45ccf389b5be1742dd70e813acf79674657dad27e2
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/Layers/W1/BaseApp/Purchases/History/UndoPurchaseReceiptLine.Codeunit.al
    title: src/Layers/W1/BaseApp/Purchases/History/UndoPurchaseReceiptLine.Codeunit.al (releases/29.x)
    date: null
    commit: ea08af5ef2d6a9b5c5af4a029288abbe2c883220
    t: null
    quote: null
links:
  learn: []
  objects: []
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
  changes:
    - change/bcapps/11367
    - change/bcapps/11274
    - change/bcapps/10290
    - change/bcapps/10005
object_type: codeunit
object_id: 5813
name: Undo Purchase Receipt Line
namespace: Microsoft.Purchases.History
app: Base Application
extends: null
first_version: "23"
last_version: "30"
present_in:
  - "23"
  - "24"
  - "25"
  - "26"
  - "27"
  - "28"
  - "29"
  - "30"
changed_in:
  - "24"
  - "25"
  - "26"
  - "27"
  - "28"
source_major: "29"
obsolete: null
countries: []
ms_search_form_ids: []
counts:
  fields: 0
  procedures: 50
  events: 31
  subscribers: 1
relations:
  out: 1
  referenced_by: 0
  pages: 0
  extended_by: 0
  event_subscribers: 2
  calls: 7
  called_by: 2
  implements: 0
---

# Codeunit 5813 "Undo Purchase Receipt Line"

> Codeunit 5813 "Undo Purchase Receipt Line" in Base Application (Microsoft.Purchases.History). 5 public procedures, 31 events, 1 event subscribers. Present since at least BC23, still in BC30, changed in BC24-28.

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

## Properties

| Property | Value |
|---|---|
| TableNo | Purch. Rcpt. Line |
| Permissions | TableData "Purchase Line" = rimd, TableData "Purch. Rcpt. Line" = rimd, TableData "Item Entry Relation" = ri, TableData "Whse. Item Entry Relation" = rimd |

## Events published

- `OnAfterCode(var PurchRcptLine: Record "Purch. Rcpt. Line"; var UndoPostingManagement: Codeunit "Undo Posting Management")` (integration)
- `OnAfterCopyItemJnlLineFromPurchRcpt(var ItemJournalLine: Record "Item Journal Line"; PurchRcptHeader: Record "Purch. Rcpt. Header"; var PurchRcptLine: Record "Purch. Rcpt. Line"; var WhseUndoQty: Codeunit "Whse. Undo Quantity"; var ItemLedgEntryNo: Integer; var NextLineNo: Integer; var TempWhseJnlLine: Record "Warehouse Journal Line" temporary; var TempGlobalItemLedgerEntry: Record "Item Ledger Entry" temporary; var TempGlobalItemEntryRelation: Record "Item Entry Relation" temporary; var IsHandled: Boolean)` (integration)
  - subscribers: [Codeunit 6225 "Sust. Purchase Subscriber"](../codeunit/6225.md) OnAfterCopyItemJnlLineFromPurchRcptForUndoPurchaseReceipt
- `OnAfterInsertNewReceiptLine(var PurchRcptLine: Record "Purch. Rcpt. Line"; PostedWhseReceiptLine: Record "Posted Whse. Receipt Line"; var PostedWhseRcptLineFound: Boolean; DocLineNo: Integer; var PostedWhseRcptLine: Record "Posted Whse. Receipt Line")` (integration)
- `OnCodeOnBeforeFindPostedWhseRcptLine(var PurchRcptLine: Record "Purch. Rcpt. Line"; var ShouldFindPostedWhseRcptLine: Boolean)` (integration)
- `OnAfterNewPurchRcptLineInsert(var NewPurchRcptLine: Record "Purch. Rcpt. Line"; OldPurchRcptLine: Record "Purch. Rcpt. Line"; var TempGlobalItemEntryRelation: Record "Item Entry Relation" temporary; var SkipInsertItemEntryRelation: Boolean)` (integration)
- `OnAfterPurchRcptLineModify(var PurchRcptLine: Record "Purch. Rcpt. Line"; var TempWhseJnlLine: Record "Warehouse Journal Line" temporary; DocLineNo: Integer; var UndoPostingManagement: Codeunit "Undo Posting Management")` (integration)
- `OnAfterUpdateOrderLine(var PurchRcptLine: Record "Purch. Rcpt. Line"; var PurchLine: Record "Purchase Line")` (integration)
- `OnBeforeBlanketOrderInitOutstanding(var BlanketOrderPurchaseLine: Record "Purchase Line"; PurchRcptLine: Record "Purch. Rcpt. Line")` (integration)
- `OnBeforeCheckPurchRcptLine(var PurchRcptLine: Record "Purch. Rcpt. Line"; var IsHandled: Boolean; var TempItemLedgerEntry: Record "Item Ledger Entry" temporary)` (integration)
- `OnBeforeCode(var PurchRcptLine: Record "Purch. Rcpt. Line"; var UndoPostingManagement: Codeunit "Undo Posting Management")` (integration)
- `OnBeforeCheckPurchRcptLines(var PurchRcptLine: Record "Purch. Rcpt. Line"; var Window: Dialog; var IsHandled: Boolean)` (integration)
- `OnBeforeGetCorrectionLineNo(PurchRcptLine: Record "Purch. Rcpt. Line"; var Result: Integer; var IsHandled: Boolean)` (integration)
- `OnBeforeNewPurchRcptLineInsert(var NewPurchRcptLine: Record "Purch. Rcpt. Line"; OldPurchRcptLine: Record "Purch. Rcpt. Line")` (integration)
- `OnBeforeOnRun(var PurchRcptLine: Record "Purch. Rcpt. Line"; var IsHandled: Boolean; var SkipTypeCheck: Boolean; var HideDialog: Boolean)` (integration)
- `OnBeforePostItemJnlLine(var PurchRcptLine: Record "Purch. Rcpt. Line"; DocLineNo: Integer; var ItemLedgEntryNo: Integer; var IsHandled: Boolean; var NewDocLineNo: Integer; var TempWarehouseJournalLine: Record "Warehouse Journal Line" temporary)` (integration)
- `OnBeforePurchRcptLineModify(var PurchRcptLine: Record "Purch. Rcpt. Line"; var TempWarehouseJournalLine: Record "Warehouse Journal Line" temporary)` (integration)
- `OnBeforeReapplyJobConsumptionFromApplyToEntryList(PurchRcptHeader: Record "Purch. Rcpt. Header"; PurchRcptLine: Record "Purch. Rcpt. Line"; ItemJnlLine: Record "Item Journal Line"; var TempApplyToEntryList: Record "Item Ledger Entry" temporary; var IsHandled: Boolean)` (integration)
- `OnBeforeUpdateBlanketOrder(var PurchRcptLine: Record "Purch. Rcpt. Line"; var IsHandled: Boolean)` (integration)
- `OnBeforeUpdateOrderLine(var PurchRcptLine: Record "Purch. Rcpt. Line"; var IsHandled: Boolean)` (integration)
- `OnPostItemJournalInboundItemEntryPostingWithJob(var ItemJournalLine: Record "Item Journal Line"; ItemApplicationEntry: Record "Item Application Entry"; var IsHandled: Boolean)` (integration)
- `OnPostItemJnlLineOnAfterCollectItemLedgEntries(var PurchRcptHeader: Record "Purch. Rcpt. Header"; var PurchRcptLine: Record "Purch. Rcpt. Line"; SourceCodeSetup: Record "Source Code Setup"; var IsHandled: Boolean)` (integration)
- `OnPostItemJnlLineOnAfterInsertTempWhseJnlLine(PurchRcptLine: Record "Purch. Rcpt. Line"; var ItemJnlLine: Record "Item Journal Line"; var TempWhseJnlLine: Record "Warehouse Journal Line" temporary; var NextLineNo: Integer)` (integration)
- `OnPostItemJnlLineOnBeforeUndoPosting(var ItemJournalLine: Record "Item Journal Line"; var PurchRcptHeader: Record "Purch. Rcpt. Header"; var PurchRcptLine: Record "Purch. Rcpt. Line"; SourceCodeSetup: Record "Source Code Setup"; var IsHandled: Boolean)` (integration)
- `OnPostItemJnlLineOnBeforeUndoValuePostingWithJob(PurchRcptHeader: Record "Purch. Rcpt. Header"; PurchRcptLine: Record "Purch. Rcpt. Line"; var ItemJnlLine: Record "Item Journal Line"; var IsHandled: Boolean)` (integration)
- `OnUpdateOrderLineOnBeforeUpdatePurchLine(var PurchRcptLine: Record "Purch. Rcpt. Line"; var PurchaseLine: Record "Purchase Line")` (integration)
- `OnCheckPurchRcptLinesAfterPurchRcptLineSetFilters(var PurchRcptLine: Record "Purch. Rcpt. Line")` (integration)
- `OnCheckPurchRcptLineOnBeforeCollectItemLedgEntries(var PurchRcptLine: Record "Purch. Rcpt. Line"; var TempItemLedgEntry: Record "Item Ledger Entry" temporary; var IsHandled: Boolean)` (integration)
- `OnCodeOnBeforeLoopPurchRcptLine(var PurchRcptLine: Record "Purch. Rcpt. Line")` (integration)
- `OnBeforeCheckPurchRcptLineFields(var PurchRcptLine: Record "Purch. Rcpt. Line"; var IsHandled: Boolean)` (integration, obsolete 28.0)
- `OnCodeOnBeforeMakeInventoryAdjustment(var PurchaseLine: Record "Purchase Line"; var PurchaseReceiptLine: Record "Purch. Rcpt. Line")` (integration)
- `OnUpdateItemJnlLineProdOrderSubcontracting(var ItemJnlLine: Record "Item Journal Line"; var PurchRcptLine: Record "Purch. Rcpt. Line"; var TempOutputItemLedgerEntry: Record "Item Ledger Entry" temporary; var OneLinePostingUndo: Boolean)` (integration)
  - subscribers: [Codeunit 99000784 "Mfg. Undo Purch. Rcpt. Line"](../codeunit/99000784.md) OnUpdateItemJnlLineProdOrderSubcontracting

## Event subscriptions

- OnSetItemAdjmtPropertiesOnBeforeCheckModifyItem subscribes to Codeunit "Item Jnl.-Post Line" OnSetItemAdjmtPropertiesOnBeforeCheckModifyItem

## Procedures

- `SetHideDialog(NewHideDialog: Boolean)`
- `UpdateOrderLine(PurchRcptLine: Record "Purch. Rcpt. Line")`
- `UpdateBlanketOrder(PurchRcptLine: Record "Purch. Rcpt. Line")`
- `HasInvoicedNotReturnedQuantity(PurchRcptLine: Record "Purch. Rcpt. Line"): Boolean`
- `IsUndoSalesShipmentLineForDropShipment(NewUndoSalesShptLineExists: Boolean)`

Plus 13 local procedures.

## Triggers

OnRun

## Relations

- runs on [Table 121 "Purch. Rcpt. Line"](../table/121.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 5817 "Undo Posting Management"](../codeunit/5817.md) (14 calls: `CheckPurchRcptLine → CheckItemLedgEntries`, `CheckPurchRcptLine → CollectItemLedgEntries`, `CheckPurchRcptLine → CollectOutputItemLedgEntriesForSubcontructingPurcReceiptLine`, …)
- [Codeunit 7320 "Whse. Undo Quantity"](../codeunit/7320.md) (5 calls: `Code → FindPostedWhseRcptLine`, `Code → PostTempWhseJnlLine`, `Code → UndoPostedWhseRcptLine`, …)
- [Codeunit 5815 "Undo Sales Shipment Line"](../codeunit/5815.md) (3 calls: `UndoDropShipmentPurchRcptLine → (object)`, `UndoDropShipmentPurchRcptLine → SetCalledFromUndoPurchaseReceiptLine`, `UndoDropShipmentPurchRcptLine → SetHideDialog`)
- [Codeunit 5402 "Unit of Measure Management"](../codeunit/5402.md) (2 calls: `PostItemJnlLine → CalcBaseQty`, `UpdateBlanketOrder → QtyRndPrecision`)
- [Codeunit 5894 "Inventory Adjustment Handler"](../codeunit/5894.md) (2 calls: `MakeInventoryAdjustment → MakeAutomaticInventoryAdjustment`, `MakeInventoryAdjustment → SetJobUpdateProperties`)
- [Codeunit 22 "Item Jnl.-Post Line"](../codeunit/22.md) (1 call: `PostItemJnlLine → UndoValuePostingWithJob`)
- [Codeunit 5801 "Show Applied Entries"](../codeunit/5801.md) (1 call: `ReapplyJobConsumptionFromApplyToEntryList → FindAppliedEntries`)

## Called by

- [Codeunit 5815 "Undo Sales Shipment Line"](../codeunit/5815.md) (3 calls: `UndoPurchaseReceiptLineForDropShipment → (object)`, `UndoPurchaseReceiptLineForDropShipment → IsUndoSalesShipmentLineForDropShipment`, `UndoPurchaseReceiptLineForDropShipment → SetHideDialog`)
- [Page 137 "Posted Purchase Rcpt. Subform"](../page/137.md) (1 call: `UndoReceiptLine → (object)`)

## Recent changes

- 2026-09-17 [#11367 [29.X][Repair Item][SaaS][Drop shipment reversal] Undo Shipment fails with blank Bin Code at bin-mandatory location](../../changes/bcapps/11367.md) (releases/29.x, BC29, fix)
- 2026-09-14 [#11274 [Master]-[Drop shipment reversal] Undo Shipment fails with blank Bin Code at bin-mandatory location](../../changes/bcapps/11274.md) (main, BC30, fix)
- 2026-08-18 [#10290 [Main] -Drop shipment undo receipt fails for service and non-inventory items.](../../changes/bcapps/10290.md) (main, BC30, fix)
- 2026-08-06 [#10005 Improve error messages when there are no quantities to reverse in shipped/received lines in Sales/Purchase/Transfer](../../changes/bcapps/10005.md) (main, BC30, fix)

## Across versions

- Present in: BC23-30
- Changed (declaration) in: BC24-28

## Deprecations

- procedure OnBeforeCheckPurchRcptLineFields: Pending 28.0 (#if not CLEAN28), "This event is no longer used."

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: "Undo Purchase Receipt Line")`, then `bcatlas_get_procedure_body` or `bcatlas_get_neighbors` on the returned id.
