Skip to content
D365 Reference

SalesTable

worksheet header

Sales order header — one row per order carrying customer, status, site, and requested dates

Module: Sales & MarketingCompany-partitioned (DataAreaId)

Header & line

SalesTable is the header for its lines in SalesLine.

Fields

28 fields · 1 key

KeyFieldEDTDescriptionTypeLengthFlags
KeySalesIdSalesIdThe sales order number — the natural key sales lines join back onstring20
CustAccountCustAccountCustomer account the order is forstring20
SalesStatusOrder status across its life cycleenum
SalesNameFree-text order descriptionstring60
InventSiteIdInventSiteIdDefault site for the orderstring10
ReceiptDateRequestedRequested receipt date; the primary analysis date for the headerdate
InvoiceAccountCustAccountCustomer account the order will be invoiced to (can differ from the ordering account)string20
CustGroupCustGroupIdCustomer group of the ordering customer, copied to the orderstring10
SalesTypeType of order (journal, subscription, sales order, returned order…)enum
CurrencyCodeCurrencyCodeTransaction currency of the orderstring3
DeliveryDateDelivery date on the order headerdate
ShippingDateRequestedRequested ship date for the orderdate
ShippingDateConfirmedConfirmed ship date; unset until confirmation, so rows carry the 1900-01-01 sentineldate
ReceiptDateConfirmedConfirmed receipt date; unset until confirmation, so rows carry the 1900-01-01 sentineldate
InventLocationIdInventLocationIdDefault warehouse for the orderstring10
DlvModeMode of delivery for the orderstring10
DlvTermTerms of delivery for the orderstring10
PaymentTerms of payment for the order (note: the column is Payment, not PaymTermId)string10
TaxGroupTaxGroupSales tax group for the orderstring10
CustomerRefThe customer's own reference for the orderstring
PurchOrderFormNumThe customer's purchase order numberstring
SalesOriginIdSales origin (channel) code recording where the order came fromstring10
SalesPoolIdSales pool used to group orders for processing and reportingstring10
SalesGroupCommission sales group on the orderstring10
WorkerSalesTakerRecIdRecId of the worker who took the order (references the HR worker table)int64
WorkerSalesResponsibleRecIdRecId of the worker responsible for the order (references the HR worker table)int64
LanguageIdLanguage documents for the order are printed instring10
DeliveryPostalAddressRecIdRecId of the order's ship-to address in LogisticsPostalAddressint64

Field provenance: hand-curated.

Boilerplate SQL

Starting point for reading SalesTableon Databricks — enums are decoded, 1900-01-01 dates are wrapped to NULL, and the DataAreaId anchor is in place. Set your Unity Catalog location, company, and filter values below; they’re substituted into the SQL and the copy button.

Query parameters
-- ============================================================
-- Table  : SalesTable Sales order header — one row per order carrying customer, status, site, and requested dates
-- Purpose: Column-selected read of SalesTable — auto-generated from field metadata
-- Grain  : One row per company (dataareaid) + SalesId
-- Notes  : Auto-generated skeleton for Synapse Link / Fabric Link-landed F&O data (lowercase column names). Enums decoded inline where verified; datetimes stored in UTC; 1900-01-01 dates are sentinels mapped to NULL. System/audit columns omitted — see the quirks guide.
-- ============================================================
SELECT
  so.salesid AS "The sales order number — the natural key sales lines join back on",
  so.custaccount AS "Customer account the order is for",
  CASE so.salesstatus WHEN 0 THEN 'None' WHEN 1 THEN 'Backorder' WHEN 2 THEN 'Delivered' WHEN 3 THEN 'Invoiced' WHEN 4 THEN 'Canceled' ELSE CAST(so.salesstatus AS STRING) END AS "Order status across its life cycle",  -- enum: SalesStatus
  so.salesname AS "Free-text order description",
  so.inventsiteid AS "Default site for the order",
  so.receiptdaterequested AS "Requested receipt date; the primary analysis date for the header",
  so.invoiceaccount AS "Customer account the order will be invoiced to (can differ from the ordering account)",
  so.custgroup AS "Customer group of the ordering customer, copied to the order",
  so.salestype AS "Type of order (journal, subscription, sales order, returned order…)",  -- enum: decode so.salestype via GlobalOptionsetMetadata join — see quirks guide #enums
  so.currencycode AS "Transaction currency of the order",
  so.deliverydate AS "Delivery date on the order header",
  so.shippingdaterequested AS "Requested ship date for the order",
  CASE WHEN CAST(so.shippingdateconfirmed AS DATE) = DATE '1900-01-01' THEN NULL ELSE CAST(so.shippingdateconfirmed AS DATE) END AS "Confirmed ship date; unset until confirmation, so rows carry the 1900-01-01 sentinel",  -- 1900-01-01 sentinel → NULL
  CASE WHEN CAST(so.receiptdateconfirmed AS DATE) = DATE '1900-01-01' THEN NULL ELSE CAST(so.receiptdateconfirmed AS DATE) END AS "Confirmed receipt date; unset until confirmation, so rows carry the 1900-01-01 sentinel",  -- 1900-01-01 sentinel → NULL
  so.inventlocationid AS "Default warehouse for the order",
  so.dlvmode AS "Mode of delivery for the order",
  so.dlvterm AS "Terms of delivery for the order",
  so.payment AS "Terms of payment for the order (note: the column is Payment, not PaymTermId)",
  so.taxgroup AS "Sales tax group for the order",
  so.customerref AS "The customer's own reference for the order",
  so.purchorderformnum AS "The customer's purchase order number",
  so.salesoriginid AS "Sales origin (channel) code recording where the order came from",
  so.salespoolid AS "Sales pool used to group orders for processing and reporting",
  so.salesgroup AS "Commission sales group on the order",
  so.workersalestaker AS "RecId of the worker who took the order (references the HR worker table)",
  so.workersalesresponsible AS "RecId of the worker responsible for the order (references the HR worker table)",
  so.languageid AS "Language documents for the order are printed in",
  so.deliverypostaladdress AS "RecId of the order's ship-to address in LogisticsPostalAddress"
FROM <catalog>.<schema>.salestable so
-- Resolve LogisticsPostalAddress (via DeliveryPostalAddress): uncomment to join on its RecId surrogate key
-- LEFT JOIN <catalog>.<schema>.logisticspostaladdress log ON log.recid = so.deliverypostaladdress
WHERE
  so.dataareaid = '<company>'
  -- AND so.salesid = '<SalesId>'
  -- AND so.receiptdaterequested >= '<DATE_FROM>'  -- yyyy-MM-dd (UTC)
  -- AND so.receiptdaterequested <= '<DATE_TO>'  -- yyyy-MM-dd (UTC)
ORDER BY so.salesid;

6 parameters not filled: <catalog>, <schema>, <company>, <SalesId>, <DATE_FROM>, <DATE_TO>

Relationships

1-hop neighbors — click a table to navigate there. RecId and InventDim edges are highlighted; they’re the joins newcomers most often get wrong.

Join details

  • SalesTableSalesLineheader line · 1:N
    ON salestable.salesid = salesline.salesid
  • SalesTableCustTableforeign key · N:1
    ON salestable.custaccount = custtable.accountnum
  • SalesTableLogisticsPostalAddressRecId ref · N:1
    ON salestable.deliverypostaladdress = logisticspostaladdress.recid

Data Entities That Expose This Table