---
id: object/codeunit/8063
type: object
title: Codeunit 8063 "Sales Documents"
summary: Codeunit 8063 "Sales Documents" in Subscription Billing (Microsoft.SubscriptionBilling). 9 public procedures, 15 events, 35 event subscribers. Introduced in BC29, still in BC30.
tier: official
language: en
tags:
  - codeunit
  - subscription billing
versions:
  introduced: "29"
  last_changed: null
  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: 0f8903db0f45231d80fb61ad26435511626f2070b65276ffd5c8e615f4104b48
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/Apps/W1/Subscription%20Billing/app/Billing/Codeunits/SalesDocuments.Codeunit.al
    title: src/Apps/W1/Subscription Billing/app/Billing/Codeunits/SalesDocuments.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/11059
    - change/bcapps/8553
object_type: codeunit
object_id: 8063
name: Sales Documents
namespace: Microsoft.SubscriptionBilling
app: Subscription Billing
extends: null
first_version: "29"
last_version: "30"
present_in:
  - "29"
  - "30"
changed_in: []
source_major: "29"
obsolete: null
countries: []
ms_search_form_ids: []
counts:
  fields: 0
  procedures: 74
  events: 15
  subscribers: 35
relations:
  out: 0
  referenced_by: 0
  pages: 0
  extended_by: 0
  event_subscribers: 0
  calls: 0
  called_by: 0
  implements: 0
---

# Codeunit 8063 "Sales Documents"

> Codeunit 8063 "Sales Documents" in Subscription Billing (Microsoft.SubscriptionBilling). 9 public procedures, 15 events, 35 event subscribers. Introduced in BC29, still in BC30.

Subscription Billing · Microsoft.SubscriptionBilling · BC29-30 · [source at ea08af5e](https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/Apps/W1/Subscription%20Billing/app/Billing/Codeunits/SalesDocuments.Codeunit.al) · facts from BC29

## Properties

| Property | Value |
|---|---|
| SingleInstance | true |

## Events published

- `OnCheckResetValueForSubscriptionItems(var TempSalesLine: Record "Sales Line"; var ResetValueForSubscriptionItems: Boolean; var IsHandled: Boolean)` (integration)
- `OnCreateSubscriptionHeaderFromSalesLineBeforeInsertSubscriptionHeader(var SubscriptionHeader: Record "Subscription Header"; SalesHeader: Record "Sales Header"; SalesLine: Record "Sales Line")` (integration)
- `OnCreateSubscriptionHeaderFromSalesLineAfterInsertSubscriptionHeader(var SubscriptionHeader: Record "Subscription Header"; SalesHeader: Record "Sales Header"; SalesLine: Record "Sales Line")` (integration)
- `OnCreateSubscriptionHeaderFromSalesLineBeforeInsertSubscriptionLine(var SubscriptionLine: Record "Subscription Line"; SalesSubscriptionLine: Record "Sales Subscription Line"; SalesLine: Record "Sales Line")` (integration)
- `OnCreateSubscriptionHeaderFromSalesLineAfterInsertSubscriptionLine(var SubscriptionLine: Record "Subscription Line"; SalesSubscriptionLine: Record "Sales Subscription Line"; SalesLine: Record "Sales Line")` (integration)
- `OnBeforeCreateSubscriptionHeaderFromSalesLine(SubscriptionHeader: Record "Subscription Header"; SalesHeader: Record "Sales Header"; SalesLine: Record "Sales Line"; SerialNo: Code[50]; QtyPerSerialNo: Decimal; var IsHandled: Boolean)` (integration)
- `OnAfterCreateSubscriptionHeaderFromSalesLine(SubscriptionHeader: Record "Subscription Header"; SalesHeader: Record "Sales Header"; SalesLine: Record "Sales Line")` (integration)
- `OnAfterInsertBillingLineArchiveOnMoveBillingLineToBillingLineArchive(var BillingLineArchive: Record "Billing Line Archive"; BillingLine: Record "Billing Line")` (integration)
- `OnBeforeMoveBillingLineToBillingLineArchiveForPostingPreview(SalesInvoiceHeader: Record "Sales Invoice Header"; var IsHandled: Boolean)` (integration)
- `OnBeforeClearQtyToInvoiceOnForSubscriptionItem(var SalesLine: Record "Sales Line"; var IsHandled: Boolean)` (integration)
- `OnAfterSalesLineShouldSkipInvoicing(var SalesLine: Record "Sales Line"; SkipTemporaryCheck: Boolean; var Result: Boolean)` (integration)
- `OnAfterSkipInsertingSalesInvoiceLineIfServiceCommitmentItemsExist(SalesHeader: Record "Sales Header"; SalesLine: Record "Sales Line"; var IsHandled: Boolean)` (integration)
- `OnUpdateQuantitiesOnPostUpdateOrderLineOnSetDefaultQtyBlankOnAfterCalcShouldModifySalesLine(var TempSalesLine: Record "Sales Line" temporary; var ShouldModifySalesLine: Boolean)` (integration)
- `OnRevertInvoicedQuantityOnUpdateSalesLineOnBeforeSalesLineModifyOnAfterCalcShouldModifySalesLine(var SalesLine: Record "Sales Line"; var ShouldModifySalesLine: Boolean)` (integration)
- `OnSetQtyToInvoiceToZeroOnBeforePostUpdateOrderLineModifyTempLineOnAfterCalcShouldModifySalesLine(var TempSalesLine: Record "Sales Line" temporary; var ShouldModifySalesLine: Boolean)` (integration)

## Event subscriptions

- SalesHeaderOnBeforeDeleteEvent subscribes to Table "Sales Header" OnBeforeDeleteEvent
- SalesLineOnAfterDeleteEvent subscribes to Table "Sales Line" OnBeforeDeleteEvent
- SetVATProductPostingGroupInContractRenewalLineOnAfterAssignFieldsForNo subscribes to Table "Sales Line" OnAfterAssignFieldsForNo
- SalesPostOnBeforeSalesLineDeleteAll subscribes to Codeunit "Sales-Post" OnBeforeDeleteAfterPosting
- ValidateQuantityOnSalesLineOnBeforeInsertSalesOrderLine subscribes to Codeunit "Sales-Quote to Order" OnBeforeInsertSalesOrderLine
- BlanketSalesOrderToOrderValidateQuantityOnSalesLineOnBeforeInsertSalesOrderLine subscribes to Codeunit "Blanket Sales Order to Order" OnBeforeInsertSalesOrderLine
- ClearQtyToInvoiceForServiceCommitmentItemAfterValidateEventQtyToInvoice subscribes to Table "Sales Line" OnAfterValidateEvent (Qty. to Invoice)
- ClearQtyToInvoiceForServiceCommitmentItemAfterInitQtyToInvoice subscribes to Table "Sales Line" OnAfterInitQtyToInvoice
- ResetValueForServiceCommitmentItemsBeforePosting subscribes to Codeunit "Sales-Post" OnAfterCopyToTempLines
- RestoreValueForServiceCommitmentItemsAfterPosting subscribes to Codeunit "Sales-Post" OnPostUpdateOrderLineOnBeforeInitOutstanding
- SkipInitializingPostingNo subscribes to Codeunit "Sales-Post" OnBeforeUpdatePostingNo
- SkipInsertingSalesInvoiceHeaderIfOnlyServiceCommitmentItemsExist subscribes to Codeunit "Sales-Post" OnInsertPostedHeadersOnBeforeInsertInvoiceHeader
- SkipInsertingSalesInvoiceLineIfServiceCommitmentItemsExist subscribes to Codeunit "Sales-Post" OnPostSalesLineOnBeforeInsertInvoiceLine
- CacheSalesLineContextFromSalesPost subscribes to Codeunit "Sales-Post" OnBeforePostItemJnlLine
- CacheSalesLineContextFromDropShipment subscribes to Codeunit "Purch.-Post" OnPostAssocItemJnlLineOnBeforePost
- CreateSubscriptionHeaderFromItemJournalLine subscribes to Codeunit "Item Jnl.-Post Line" OnAfterPostItemJnlLine
- CloseSalesOrderLineOnDropShipmentAssocOrderUpdate subscribes to Codeunit "Purch.-Post" OnUpdateAssocOrderOnBeforeSalesOrderLineModify
- UpdateQuantitiesOnPostUpdateOrderLineOnSetDefaultQtyBlank subscribes to Codeunit "Sales-Post" OnPostUpdateOrderLineOnSetDefaultQtyBlank
- UpdateInvoicedQtyOnShipmentLineOnBeforeModifySalesShptLine subscribes to Codeunit "Sales-Post" OnInsertShipmentLineOnAfterInitQuantityFields
- SetQtyToInvoiceToZeroOnBeforePostUpdateOrderLineModifyTempLine subscribes to Codeunit "Sales-Post" OnBeforePostUpdateOrderLineModifyTempLine
- SkipInvoiceOrShipFlagCheckForSubscriptionBillingOnBeforeCheckHeaderPostingType subscribes to Codeunit "Sales-Post" OnBeforeCheckHeaderPostingType
- SkipQuantityCheckForSubscriptionBillingOnBeforeSalesLineFind subscribes to Codeunit "Release Sales Document" OnBeforeSalesLineFind
- ForceInvoiceCreationForZeroQtyDocumentOnBeforeCalcInvoice subscribes to Codeunit "Sales-Post" OnBeforeCalcInvoice
- SetEverythingInvoicedForZeroQtyDocumentOnAfterSetEverythingInvoiced subscribes to Codeunit "Sales-Post" OnPostSalesLineOnAfterSetEverythingInvoiced
- ModifyShipmentDateFromInventoryPickPostingDate subscribes to Codeunit "Whse.-Activity-Post" OnUpdateSourceDocumentOnAfterSalesLineModify
- TransferRecurringBillingMark subscribes to Codeunit "Gen. Jnl.-Post Line" OnBeforeCustLedgEntryInsert
- HideConfirmKeepExistingDimensions subscribes to Table "Sales Header" OnBeforeConfirmKeepExistingDimensions
- SalesInvLineCopyContractNoOnAfterInitFromSalesLine subscribes to Table "Sales Invoice Line" OnAfterInitFromSalesLine
- SalesCrMemoLineCopyContractNoOnAfterInitFromSalesLine subscribes to Table "Sales Cr.Memo Line" OnAfterInitFromSalesLine
- RevertInvoicedQuantityOnUpdateSalesLineOnBeforeSalesLineModify subscribes to Codeunit "Undo Posting Management" OnUpdateSalesLineOnBeforeSalesLineModify
- ClearQtyToInvoiceInSalesLineForServiceCommitmentItem subscribes to Codeunit "Copy Document Mgt." OnCopySalesDocLineOnBeforeCopyThisLine
- UpdateInvoicedQtyOnSalesLineAfterUndoShipment subscribes to Codeunit "Undo Posting Management" OnUpdateSalesLineOnBeforeInitOustanding
- FindSubscriptionOnAfterGetRecRefAndFieldsNoByType subscribes to Codeunit "Find Record Management" OnAfterGetRecRefAndFieldsNoByType
- ResetVariablesOnBeforePostSalesDoc subscribes to Codeunit "Sales-Post" OnBeforePostSalesDoc
- ResetVariablesOnAfterPostSalesDoc subscribes to Codeunit "Sales-Post" OnAfterPostSalesDoc

## Procedures

- `MoveBillingLineToBillingLineArchiveForPostingPreview(SalesInvoiceHeader: Record "Sales Invoice Header")` (internal)
- `CreateServiceObjectFromSales(var SalesHeader: Record "Sales Header"; var SalesLine: Record "Sales Line"; var SalesShptLine: Record "Sales Shipment Line")` (obsolete 29.0: Use OnAfterPostItemJnlLine event subscriber to create Subscription Headers during item journal posting)
- `CreateSubscriptionLineFromSalesLine(ServiceObject: Record "Subscription Header"; SalesHeader: Record "Sales Header"; SalesLine: Record "Sales Line")`
- `AllSalesLinesAreServiceCommitmentItems(SalesHeader: Record "Sales Header"): Boolean`
- `SetCalledFromContractRenewal(NewCalledFromContractRenewal: Boolean)` (internal)
- `IsInvoiceCredited(DocumentNo: Code[20]): Boolean` (internal)
- `GetAppliesToDocNo(SalesHeader: Record "Sales Header"): Code[20]` (internal)
- `SalesLineShouldSkipInvoicing(var SalesLine: Record "Sales Line"): Boolean`
- `SalesLineShouldSkipInvoicing(var SalesLine: Record "Sales Line"; SkipTemporaryCheck: Boolean): Boolean`

Plus 15 local procedures.

## Recent changes

- 2026-09-08 [#11059 Hardening subscription billing + drop shipment scenarios](../../changes/bcapps/11059.md) (main, BC30, fix)
- 2026-07-30 [#8553 [Bug][SubscriptionBilling]: Performance: Billing document creation does not scale to large datasets (4M+ subscription lines)](../../changes/bcapps/8553.md) (main, BC30, performance)

## Across versions

- Present in: BC29-30
- Changed (declaration) in: none

## Deprecations

- procedure CreateServiceObjectFromSales: Pending 29.0 (#if not CLEAN28), "Use OnAfterPostItemJnlLine event subscriber to create Subscription Headers during item journal posting"

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). 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: "Sales Documents")`, then `bcatlas_get_procedure_body` or `bcatlas_get_neighbors` on the returned id.
