---
id: object/codeunit/5816
type: object
title: Codeunit 5816 "Undo Return Receipt Line"
summary: Codeunit 5816 "Undo Return Receipt Line" in Base Application (Microsoft.Sales.History). 2 public procedures, 19 events, 1 event subscribers. Present since at least BC23, still in BC30, changed in BC26.
tier: official
language: en
tags:
  - codeunit
  - base application
versions:
  introduced: null
  last_changed: "26"
  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: 7d31b91f3a543c1c068e4fae49b29f0e7e7a7401c57d2802e449db962fdefdb5
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/Layers/W1/BaseApp/Sales/History/UndoReturnReceiptLine.Codeunit.al
    title: src/Layers/W1/BaseApp/Sales/History/UndoReturnReceiptLine.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/10005
object_type: codeunit
object_id: 5816
name: Undo Return Receipt Line
namespace: Microsoft.Sales.History
app: Base Application
extends: null
first_version: "23"
last_version: "30"
present_in:
  - "23"
  - "24"
  - "25"
  - "26"
  - "27"
  - "28"
  - "29"
  - "30"
changed_in:
  - "26"
source_major: "29"
obsolete: null
countries: []
ms_search_form_ids: []
counts:
  fields: 0
  procedures: 30
  events: 19
  subscribers: 1
relations:
  out: 1
  referenced_by: 0
  pages: 0
  extended_by: 0
  event_subscribers: 0
  calls: 4
  called_by: 1
  implements: 0
---

# Codeunit 5816 "Undo Return Receipt Line"

> Codeunit 5816 "Undo Return Receipt Line" in Base Application (Microsoft.Sales.History). 2 public procedures, 19 events, 1 event subscribers. Present since at least BC23, still in BC30, changed in BC26.

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

## Properties

| Property | Value |
|---|---|
| TableNo | Return Receipt Line |
| Permissions | TableData "Sales Line" = rimd, TableData "Item Entry Relation" = ri, TableData "Whse. Item Entry Relation" = rimd, TableData "Return Receipt Line" = rimd |

## Events published

- `OnBeforeCode(ReturnReceiptLine: Record "Return Receipt Line"; HideDialog: Boolean; var IsHandled: Boolean)` (integration): Raised before the undo return receipt line process begins.
- `OnAfterCode(var ReturnReceiptLine: Record "Return Receipt Line")` (integration): Raised after the undo return receipt line process is completed.
- `OnAfterCopyItemJnlLineFromReturnRcpt(var ItemJournalLine: Record "Item Journal Line"; ReturnReceiptHeader: Record "Return Receipt Header"; ReturnReceiptLine: Record "Return Receipt Line"; var WhseUndoQty: Codeunit "Whse. Undo Quantity"; var ItemLedgEntryNo: Integer; var TempWhseJnlLine: Record "Warehouse Journal Line" temporary; var NextLineNo: Integer; ReturnRcptHeader: Record "Return Receipt Header"; var TempGlobalItemLedgEntry: Record "Item Ledger Entry" temporary; var TempGlobalItemEntryRelation: Record "Item Entry Relation" temporary; var IsHandled: Boolean)` (integration): Raised after copying the item journal line from the return receipt during the undo process.
- `OnAfterInsertNewReceiptLine(var ReturnReceiptLine: Record "Return Receipt Line"; var PostedWhseReceiptLine: Record "Posted Whse. Receipt Line"; var PostedWhseRcptLineFound: Boolean; DocLineNo: Integer; var IsHandled: Boolean)` (integration): Raised after inserting a new correction receipt line during the undo process.
- `OnAfterNewReturnRcptLineInsert(var NewReturnReceiptLine: Record "Return Receipt Line"; OldReturnReceiptLine: Record "Return Receipt Line")` (integration): Raised after inserting a new correction return receipt line during the undo process.
- `OnAfterReturnRcptLineModify(var ReturnRcptLine: Record "Return Receipt Line"; var TempWhseJnlLine: Record "Warehouse Journal Line" temporary; DocLineNo: Integer; HideDialog: Boolean)` (integration): Raised after modifying the original return receipt line during the undo process.
- `OnAfterUpdateSalesLine(var ReturnRcptLine: Record "Return Receipt Line"; var SalesLine: Record "Sales Line")` (integration): Raised after updating the related sales return order line during the undo process.
- `OnBeforeCheckReturnRcptLine(var ReturnReceiptLine: Record "Return Receipt Line"; var IsHandled: Boolean)` (integration): Raised before validating that the return receipt line can be undone.
- `OnBeforeGetCorrectionLineNo(ReturnRcptLine: Record "Return Receipt Line"; var Result: Integer; var IsHandled: Boolean)` (integration): Raised before calculating the correction line number for the undo receipt line.
- `OnBeforeOnRun(var ReturnReceiptLine: Record "Return Receipt Line"; var IsHandled: Boolean; var SkipTypeCheck: Boolean; var HideDialog: Boolean)` (integration): Raised before the undo return receipt line OnRun trigger executes.
- `OnBeforeNewReturnRcptLineInsert(var NewReturnReceiptLine: Record "Return Receipt Line"; OldReturnReceiptLine: Record "Return Receipt Line")` (integration): Raised before inserting a new correction return receipt line during the undo process.
- `OnBeforePostItemJnlLine(var ReturnReceiptLine: Record "Return Receipt Line"; DocLineNo: Integer; var ItemLedgEntryNo: Integer; var IsHandled: Boolean)` (integration): Raised before posting the item journal line during the undo return receipt process.
- `OnBeforeReturnRcptLineModify(var ReturnReceiptLine: Record "Return Receipt Line"; var TempWhseJnlLine: Record "Warehouse Journal Line" temporary)` (integration): Raised before modifying the original return receipt line during the undo process.
- `OnBeforeUpdateOrderLine(var ReturnReceiptLine: Record "Return Receipt Line"; var IsHandled: Boolean)` (integration): Raised before updating the sales return order line during the undo process.
- `OnUpdateOrderLineOnBeforeUpdateSalesLine(var ReturnReceiptLine: Record "Return Receipt Line"; var SalesLine: Record "Sales Line")` (integration): Raised before updating the sales line quantities during the undo process.
- `OnCheckReturnRcptLineOnBeforeCheckReturnQtyRcdNotInvd(var ReturnReceiptLine: Record "Return Receipt Line"; var IsHandled: Boolean)` (integration): Raised before checking the return quantity received but not invoiced during validation.
- `OnCheckReturnRcptLineOnBeforeCollectItemLedgEntries(var ReturnRcptLine: Record "Return Receipt Line"; var TempItemLedgEntry: Record "Item Ledger Entry" temporary; var IsHandled: Boolean)` (integration): Raised before collecting item ledger entries during return receipt line validation.
- `OnCodeOnBeforeCallCheckReturnRcptLine(var ReturnReceiptLine: Record "Return Receipt Line")` (integration): Raised before calling the return receipt line check during the undo process.
- `OnPostItemJnlLineOnAfterRunItemJnlPostLine(var ItemJournalLine: Record "Item Journal Line"; ReturnReceiptLine: Record "Return Receipt Line"; ReturnReceiptHeader: Record "Return Receipt Header"; var ItemJnlPostLine: Codeunit "Item Jnl.-Post Line")` (integration): Raised after running the item journal post line during the undo return receipt process.

## Event subscriptions

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

## Procedures

- `SetHideDialog(NewHideDialog: Boolean)`: Sets whether the confirmation dialog should be hidden when undoing return receipt lines.
- `UpdateOrderLine(ReturnRcptLine: Record "Return Receipt Line")`: Updates the related sales return order line after undoing a return receipt line.

Plus 8 local procedures.

## Triggers

OnRun

## Relations

- runs on [Table 6661 "Return Receipt Line"](../table/6661.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) (6 calls: `CheckReturnRcptLine → CheckItemLedgEntries`, `CheckReturnRcptLine → CollectItemLedgEntries`, `CheckReturnRcptLine → TestReturnRcptLine`, …)
- [Codeunit 7320 "Whse. Undo Quantity"](../codeunit/7320.md) (5 calls: `Code → FindPostedWhseRcptLine`, `Code → PostTempWhseJnlLine`, `Code → UndoPostedWhseRcptLine`, …)
- [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 → (object)`)

## Called by

- [Page 6661 "Posted Return Receipt Subform"](../page/6661.md) (1 call: `UndoReturnReceipt → (object)`)

## Recent changes

- 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: BC26

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