This article illustrates how to create a sales order with lines on Exact Online using the REST-based tables.

Creation of sales order is generally recommended using the Exact Online XML APIs for reasons of an approximately 3 times better throughput and an order of magnitude higher daily quotas. The XML APIs can be accessed using UploadXMLTopics or with an Excel-sheet as input.


Exact Online has the peculiarity that it requires each transaction to have at least one line, which holds for sales orders, sales invoices and general ledger transactions. However, a standard insert statement creates just the header. Therefor, the header and the lines must be sent to Exact Online in one transaction.

Invantive SQL provides transaction-logic to accomplish this. The same transaction logic is also used for other connectors such as when creating EDIFACT files.

Execution of the Invantive SQL statements below will create a sales order like:

To create such a sales execute the following steps:

  • Choose the Exact Online company:

  • Enable native call logging when you want to keep an eye on the actual communication with Exact Online using:

set trace-native-calls true

set log-native-calls-to-disk
  • The native calls are logged by default in the %USERPROFILE%\invantive\nativelog folder.

  • Start a transaction:

begin transaction
  • Define the contents of the sales order:

insert into exactonlinerest..salesorders
( orderedby
, description
-- Select a random customer and define a transaction 'TRANSACTION1',
-- one per sales order.
-- You can define and upload multiple Exact Online sales orders
-- and send them off in one Invantive SQL transaction.
,      'buy some items' description
from   exactonlinerest..accounts act
where  act.status = 'C'
limit  1
identified by 'TRANSACTION1'
  • Add ten order lines to the sales order, each on a different item:

insert into ExactOnlineREST..salesorderlines 
( item
, linenumber
,      row_number()
from   exactonlinerest..items itm
where  itm.IsSalesItem = true
limit 10
attach to 'TRANSACTION1'
  • Hand over the sales order and the associated lines to Exact Online:

commit transaction
  • After the commit, Exact Online will return validation errors if any.

  • The outgoing native call found in the log folder will resemble (line breaks added for readability):

Outbound Request using POST started at 2020-06-02 16:43:01 (UTC).
Object: ExactOnlineREST.SalesOrder.SalesOrders
Partition: 102673
Data container ID:

{"Description":"buy some items","OrderedBy":"6d0bfbeb-730f-4290-b886-007392d22a0f"
[ {"Item":"1db1fa03-4b2d-4a54-bee2-005edae3934c","LineNumber":21}
  • The native answer from Exact Online interpreted by Invantive SQL will resemble:

Inbound POST started at 2020-06-02 16:43:01 (UTC).
Object: ExactOnlineREST.SalesOrder.SalesOrders
Partition: 102673
Data container ID:

"d" : {
"__metadata": {
"uri": "'94feaad3-69cc-46ad-9925-d02d2b7f994a')"
, "type": "Exact.Web.Api.Models.SalesOrder"
, "Created": "\/Date(1591123382670)\/"
, "Creator": "bd0e191e-6fb4-4537-bf91-9f68d4e62744"
, "CreatorFullName": "John Doe"
, "Currency": "EUR"
, "DeliverTo": "6d0bfbeb-730f-4290-b886-007392d22a0f"
, "DeliverToContactPerson": null
, "DeliverToContactPersonFullName": null
, "DeliverToName": "             61602"
, "DeliveryDate": "\/Date(1591056000000)\/"
, "DeliveryStatus": 12
, "DeliveryStatusDescription": "Open"
, "DeliveryAddress": "bb8da22d-fd4f-4f8e-bd96-b0b1de61bd6a"
, "Description": "buy some items"
, "Division": 102673
, "InvoiceStatus": 12
, "InvoiceStatusDescription": "Open"
, "InvoiceTo": "6d0bfbeb-730f-4290-b886-007392d22a0f"
, "OrderedBy": "6d0bfbeb-730f-4290-b886-007392d22a0f"
, "OrderNumber": 42
, "Status": 12
, "StatusDescription": "Open"
, "SalesOrderLines": 
"__deferred": {
"uri": "'94feaad3-69cc-46ad-9925-d02d2b7f994a')/SalesOrderLines"