---
id: object/codeunit/368
type: object
title: Codeunit 368 "Format Document"
summary: Codeunit 368 "Format Document" in Base Application (Microsoft.Utilities). 18 public procedures, 12 events. Present since at least BC23, still in BC30, changed in BC25, BC28.
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: 7d65acec290f3682d5daede53e755311767be7e0646d397e40904e8343498bb4
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/Layers/W1/BaseApp/Utilities/FormatDocument.Codeunit.al
    title: src/Layers/W1/BaseApp/Utilities/FormatDocument.Codeunit.al (releases/29.x)
    date: null
    commit: ea08af5ef2d6a9b5c5af4a029288abbe2c883220
    t: null
    quote: null
links:
  learn: []
  objects: []
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
object_type: codeunit
object_id: 368
name: Format Document
namespace: Microsoft.Utilities
app: Base Application
extends: null
first_version: "23"
last_version: "30"
present_in:
  - "23"
  - "24"
  - "25"
  - "26"
  - "27"
  - "28"
  - "29"
  - "30"
changed_in:
  - "25"
  - "28"
source_major: "29"
obsolete: null
countries: []
ms_search_form_ids: []
counts:
  fields: 0
  procedures: 32
  events: 12
  subscribers: 0
relations:
  out: 0
  referenced_by: 0
  pages: 0
  extended_by: 0
  event_subscribers: 1
  calls: 2
  called_by: 67
  implements: 0
---

# Codeunit 368 "Format Document"

> Codeunit 368 "Format Document" in Base Application (Microsoft.Utilities). 18 public procedures, 12 events. Present since at least BC23, still in BC30, changed in BC25, BC28.

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

## Events published

- `OnAfterSetSalesPurchaseLine(Quantity: Decimal; UnitPrice: Decimal; VATPercentage: Decimal; LineAmount: Decimal; CurrencyCode: Code[10]; var FormattedQuantity: Text; var FormattedUnitPrice: Text; var FormattedVATPercentage: Text; var FormattedLineAmount: Text; CommentLine: Boolean)` (integration)
- `OnAfterSetSalesLine(var SalesLine: Record "Sales Line"; var FormattedQuantity: Text; var FormattedUnitPrice: Text; var FormattedVATPercentage: Text; var FormattedLineAmount: Text)` (integration)
  - subscribers: [Codeunit 8073 "Sales Report Printout Mgmt."](../codeunit/8073.md) SalesLineAddMarkToFormattedLineAmount
- `OnAfterSetSalesInvoiceLine(var SalesInvoiceLine: Record "Sales Invoice Line"; var FormattedQuantity: Text; var FormattedUnitPrice: Text; var FormattedVATPercentage: Text; var FormattedLineAmount: Text)` (integration)
- `OnAfterSetSalesCrMemoLine(var SalesCrMemoLine: Record "Sales Cr.Memo Line"; var FormattedQuantity: Text; var FormattedUnitPrice: Text; var FormattedVATPercentage: Text; var FormattedLineAmount: Text)` (integration)
- `OnAfterSetTotalLabels(CurrencyCode: Code[10]; var TotalText: Text[50]; var TotalInclVATText: Text[50]; var TotalExclVATText: Text[50])` (integration)
- `OnBeforeSetLogoPosition(var LogoPosition: Option "No Logo",Left,Center,Right; var CompanyInfo1: Record "Company Information"; var CompanyInfo2: Record "Company Information"; var CompanyInfo3: Record "Company Information"; var IsHandled: Boolean)` (integration)
- `OnBeforeSetPurchaser(var SalespersonPurchaser: Record "Salesperson/Purchaser"; Code: Code[20]; var PurchaserText: Text[50]; var IsHandled: Boolean)` (integration)
- `OnBeforeSetSalesPerson(var SalespersonPurchaser: Record "Salesperson/Purchaser"; Code: Code[20]; var SalesPersonText: Text[50]; var IsHandled: Boolean)` (integration)
- `OnBeforeSetSalesLine(var SalesLine: Record "Sales Line")` (integration)
- `OnBeforeSetSalesInvoiceLine(var SalesInvoiceLine: Record "Sales Invoice Line")` (integration)
- `OnBeforeSetSalesCrMemoLine(var SalesCrMemoLine: Record "Sales Cr.Memo Line")` (integration)
- `OnAfterHideDocumentLine(HideLinesWithZeroQuantity: Boolean; RecordVariant: Variant; QuantityFieldId: Integer; var HideLine: Boolean)` (integration)

## Procedures

- `GetRecordFiltersWithCaptions(RecVariant: Variant): Text`
- `GetCOPYText(): Text[30]`
- `ParseComment(Comment: Text[80]; var Description: Text[100]; var Description2: Text[100])`
- `SetTotalLabels(CurrencyCode: Code[10]; var TotalText: Text[50]; var TotalInclVATText: Text[50]; var TotalExclVATText: Text[50])`
- `SetLogoPosition(LogoPosition: Option "No Logo",Left,Center,Right; var CompanyInfo1: Record "Company Information"; var CompanyInfo2: Record "Company Information"; var CompanyInfo3: Record "Company Information")`
- `SetPaymentMethod(var PaymentMethod: Record "Payment Method"; Code: Code[10]; LanguageCode: Code[10])`
- `SetPaymentTerms(var PaymentTerms: Record "Payment Terms"; Code: Code[10]; LanguageCode: Code[10])`
- `SetPurchaser(var SalespersonPurchaser: Record "Salesperson/Purchaser"; Code: Code[20]; var PurchaserText: Text[50])`
- `SetShipmentMethod(var ShipmentMethod: Record "Shipment Method"; Code: Code[10]; LanguageCode: Code[10])`
- `SetSalesPerson(var SalespersonPurchaser: Record "Salesperson/Purchaser"; Code: Code[20]; var SalesPersonText: Text[50])`
- `SetText(Condition: Boolean; Caption: Text[80]): Text[80]`
- `SetSalesInvoiceLine(var SalesInvoiceLine: Record "Sales Invoice Line"; var FormattedQuantity: Text; var FormattedUnitPrice: Text; var FormattedVATPercentage: Text; var FormattedLineAmount: Text)`
- `SetSalesLine(var SalesLine: Record "Sales Line"; var FormattedQuantity: Text; var FormattedUnitPrice: Text; var FormattedVATPercentage: Text; var FormattedLineAmount: Text)`
- `SetSalesCrMemoLine(var SalesCrMemoLine: Record "Sales Cr.Memo Line"; var FormattedQuantity: Text; var FormattedUnitPrice: Text; var FormattedVATPercentage: Text; var FormattedLineAmount: Text)`
- `SetPurchaseLine(var PurchaseLine: Record "Purchase Line"; var FormattedQuantity: Text; var FormattedDirectUnitCost: Text; var FormattedVATPercentage: Text; var FormattedLineAmount: Text)`
- `SetPurchaseLine(var PurchaseLine: Record "Purchase Line"; var FormattedQuantity: Text; var FormattedDirectUnitCost: Text)`
- `HideDocumentLine(HideLinesWithZeroQuantity: Boolean; RecordVariant: Variant; QuantityFieldId: Integer): Boolean`
- `IsLineWithZeroQuantity(RecordVariant: Variant; QuantityFieldId: Integer): Boolean`

Plus 2 local procedures.

## Triggers

OnRun

## 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 1306 "Company Information Mgt."](../codeunit/1306.md) (1 call: `SetDefaultLanguageCode → GetLanguageDefault`)
- [Codeunit 45 "Auto Format"](../codeunit/45.md) (1 call: `SetSalesPurchaseLine → ResolveAutoFormat`)

## Called by

- [Report 1307 "Standard Sales - Credit Memo"](../report/1307.md) (7 calls: `FormatDocumentFields → SetPaymentMethod`, `FormatDocumentFields → SetPaymentTerms`, `FormatDocumentFields → SetSalesPerson`, …)
- [Report 1303 "Standard Sales - Draft Invoice"](../report/1303.md) (6 calls: `FormatDocumentFields → SetPaymentMethod`, `FormatDocumentFields → SetPaymentTerms`, `FormatDocumentFields → SetSalesPerson`, …)
- [Report 1306 "Standard Sales - Invoice"](../report/1306.md) (6 calls: `FormatDocumentFields → SetPaymentMethod`, `FormatDocumentFields → SetPaymentTerms`, `FormatDocumentFields → SetSalesPerson`, …)
- [Report 210 "Blanket Sales Order"](../report/210.md) (6 calls: `FormatDocumentFields → SetPaymentTerms`, `FormatDocumentFields → SetSalesPerson`, `FormatDocumentFields → SetShipmentMethod`, …)
- [Report 6222 "EUDR Sales Invoice"](../report/6222.md) (6 calls: `FormatDocumentFields → SetPaymentMethod`, `FormatDocumentFields → SetPaymentTerms`, `FormatDocumentFields → SetSalesPerson`, …)
- [Report 1304 "Standard Sales - Quote"](../report/1304.md) (5 calls: `FormatDocumentFields → SetPaymentMethod`, `FormatDocumentFields → SetPaymentTerms`, `FormatDocumentFields → SetSalesPerson`, …)
- [Report 1305 "Standard Sales - Order Conf."](../report/1305.md) (5 calls: `FormatDocumentFields → SetPaymentMethod`, `FormatDocumentFields → SetPaymentTerms`, `FormatDocumentFields → SetSalesPerson`, …)
- [Report 1322 "Standard Purchase - Order"](../report/1322.md) (5 calls: `FormatDocumentFields → SetPaymentTerms`, `FormatDocumentFields → SetPurchaser`, `FormatDocumentFields → SetShipmentMethod`, …)
- [Report 215 "Archived Sales Quote"](../report/215.md) (5 calls: `FormatDocumentFields → SetPaymentTerms`, `FormatDocumentFields → SetSalesPerson`, `FormatDocumentFields → SetShipmentMethod`, …)
- [Report 216 "Archived Sales Order"](../report/216.md) (5 calls: `FormatDocumentFields → SetPaymentTerms`, `FormatDocumentFields → SetSalesPerson`, `FormatDocumentFields → SetShipmentMethod`, …)
- [Report 405 "Order"](../report/405.md) (5 calls: `FormatDocumentFields → SetPaymentTerms`, `FormatDocumentFields → SetPurchaser`, `FormatDocumentFields → SetShipmentMethod`, …)
- [Report 406 "Purchase - Invoice"](../report/406.md) (5 calls: `FormatDocumentFields → SetPaymentTerms`, `FormatDocumentFields → SetPurchaser`, `FormatDocumentFields → SetShipmentMethod`, …)
- [Report 413 "Self Billing Invoice"](../report/413.md) (5 calls: `FormatDocumentFields → SetPaymentTerms`, `FormatDocumentFields → SetPurchaser`, `FormatDocumentFields → SetShipmentMethod`, …)
- [Report 416 "Archived Purchase Order"](../report/416.md) (5 calls: `FormatDocumentFields → SetPaymentTerms`, `FormatDocumentFields → SetPurchaser`, `FormatDocumentFields → SetShipmentMethod`, …)
- [Report 417 "Arch.Purch. Return Order"](../report/417.md) (5 calls: `FormatDocumentFields → SetPaymentTerms`, `FormatDocumentFields → SetPurchaser`, `FormatDocumentFields → SetShipmentMethod`, …)
- [Report 418 "Arch. Sales Return Order"](../report/418.md) (5 calls: `FormatDocumentFields → SetPaymentTerms`, `FormatDocumentFields → SetSalesPerson`, `FormatDocumentFields → SetShipmentMethod`, …)
- [Report 5176 "Archived Blanket Sales Order"](../report/5176.md) (5 calls: `FormatDocumentFields → SetPaymentTerms`, `FormatDocumentFields → SetSalesPerson`, `FormatDocumentFields → SetShipmentMethod`, …)
- [Report 5911 "Service - Invoice"](../report/5911.md) (5 calls: `FormatDocumentFields → SetPaymentTerms`, `FormatDocumentFields → SetSalesPerson`, `FormatDocumentFields → SetText`, …)
- [Report 5174 "Archived Blanket Purch. Order"](../report/5174.md) (4 calls: `FormatDocumentFields → SetPaymentTerms`, `FormatDocumentFields → SetPurchaser`, `FormatDocumentFields → SetShipmentMethod`, …)
- [Report 6631 "Return Order Confirmation"](../report/6631.md) (4 calls: `FormatDocumentFields → SetSalesPerson`, `FormatDocumentFields → SetText`, `FormatDocumentFields → SetTotalLabels`, …)
- [Report 1302 "Standard Sales - Pro Forma Inv"](../report/1302.md) (3 calls: `FormatDocumentFields → SetSalesPerson`, `FormatDocumentFields → SetShipmentMethod`, `FormatDocumentFields → SetTotalLabels`)
- [Report 208 "Sales - Shipment"](../report/208.md) (3 calls: `FormatDocumentFields → SetSalesPerson`, `FormatDocumentFields → SetText`, `OnInitReport → SetLogoPosition`)
- [Report 404 "Purchase - Quote"](../report/404.md) (3 calls: `FormatDocumentFields → SetPurchaser`, `FormatDocumentFields → SetShipmentMethod`, `FormatDocumentFields → SetText`)
- [Report 407 "Purchase - Credit Memo"](../report/407.md) (3 calls: `FormatDocumentFields → SetPurchaser`, `FormatDocumentFields → SetText`, `FormatDocumentFields → SetTotalLabels`)
- [Report 410 "Blanket Purchase Order"](../report/410.md) (3 calls: `FormatDocumentFields → SetPurchaser`, `FormatDocumentFields → SetShipmentMethod`, `FormatDocumentFields → SetText`)
- [Report 415 "Archived Purchase Quote"](../report/415.md) (3 calls: `FormatDocumentFields → SetPurchaser`, `FormatDocumentFields → SetShipmentMethod`, `FormatDocumentFields → SetText`)
- [Report 5912 "Service - Credit Memo"](../report/5912.md) (3 calls: `FormatDocumentFields → SetSalesPerson`, `FormatDocumentFields → SetText`, `FormatDocumentFields → SetTotalLabels`)
- [Report 5913 "Service - Shipment"](../report/5913.md) (3 calls: `FormatDocumentFields → SetSalesPerson`, `FormatDocumentFields → SetText`, `OnInitReport → SetLogoPosition`)
- [Report 6641 "Return Order"](../report/6641.md) (3 calls: `FormatDocumentFields → SetPurchaser`, `FormatDocumentFields → SetText`, `FormatDocumentFields → SetTotalLabels`)
- [Report 6646 "Sales - Return Receipt"](../report/6646.md) (3 calls: `FormatDocumentFields → SetSalesPerson`, `FormatDocumentFields → SetText`, `OnInitReport → SetLogoPosition`)
- [Report 1308 "Standard Sales - Shipment"](../report/1308.md) (2 calls: `FormatDocumentFields → SetSalesPerson`, `FormatDocumentFields → SetShipmentMethod`)
- [Report 1309 "Standard Sales - Return Rcpt."](../report/1309.md) (2 calls: `FormatDocumentFields → SetSalesPerson`, `FormatDocumentFields → SetShipmentMethod`)
- [Report 408 "Purchase - Receipt"](../report/408.md) (2 calls: `FormatDocumentFields → SetPurchaser`, `FormatDocumentFields → SetText`)
- [Report 5970 "Service Contract"](../report/5970.md) (2 calls: `FormatDocumentFields → SetSalesPerson`, `OnInitReport → SetLogoPosition`)
- [Report 6636 "Purchase - Return Shipment"](../report/6636.md) (2 calls: `FormatDocumentFields → SetPurchaser`, `FormatDocumentFields → SetText`)
- [Report 101 "Customer - List"](../report/101.md) (1 call: `OnPreReport → GetRecordFiltersWithCaptions`)
- [Report 1012 "Jobs per Customer"](../report/1012.md) (1 call: `OnPreReport → GetRecordFiltersWithCaptions`)
- [Report 104 "Customer - Detail Trial Bal."](../report/104.md) (1 call: `OnPreReport → GetRecordFiltersWithCaptions`)
- [Report 105 "Customer - Summary Aging"](../report/105.md) (1 call: `OnPreReport → GetRecordFiltersWithCaptions`)
- [Report 106 "Customer Detailed Aging"](../report/106.md) (1 call: `OnPreReport → GetRecordFiltersWithCaptions`)
- [Report 107 "Customer - Order Summary"](../report/107.md) (1 call: `OnPreReport → GetRecordFiltersWithCaptions`)
- [Report 108 "Customer - Order Detail"](../report/108.md) (1 call: `OnPreReport → GetRecordFiltersWithCaptions`)
- [Report 109 "Customer - Summary Aging Simp."](../report/109.md) (1 call: `OnPreReport → GetRecordFiltersWithCaptions`)
- [Report 111 "Customer - Top 10 List"](../report/111.md) (1 call: `OnPreReport → GetRecordFiltersWithCaptions`)
- [Report 112 "Sales Statistics"](../report/112.md) (1 call: `OnPreReport → GetRecordFiltersWithCaptions`)
- [Report 113 "Customer/Item Sales"](../report/113.md) (1 call: `UpdateRequestPageFilterValues → GetRecordFiltersWithCaptions`)
- [Report 119 "Customer - Sales List"](../report/119.md) (1 call: `OnPreReport → GetRecordFiltersWithCaptions`)
- [Report 120 "Aged Accounts Receivable"](../report/120.md) (1 call: `OnPreReport → GetRecordFiltersWithCaptions`)
- [Report 121 "Customer - Balance to Date"](../report/121.md) (1 call: `OnPreReport → GetRecordFiltersWithCaptions`)
- [Report 1701 "Deferral Summary - Sales"](../report/1701.md) (1 call: `OnPreReport → GetRecordFiltersWithCaptions`)
- and 17 more: data/code/graph/29/calls.json

## Across versions

- Present in: BC23-30
- Changed (declaration) in: BC25, BC28

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