Creating a sales order
Sales orders are used throughout the sales process to hold the information about goods or services that a company sells to its customers. Normally, sales orders are created from the user interface, but in automated processes, sales orders can be also created from code.
In this recipe, we will learn how to create a sales order from code. We will use a standard method provided by the application.
How to do it...
1. In the AOT, create a new job named
SalesOrderCreate
with the following code:static void SalesOrderCreate(Args _args) { NumberSeq numberSeq; SalesTable salesTable; SalesLine salesLine; ttsBegin; numberSeq = NumberSeq::newGetNum( SalesParameters::numRefSalesId()); numberSeq.used(); salesTable.SalesId = numberSeq.num(); salesTable.initValue(); salesTable.CustAccount = '1101'; salesTable.initFromCustTable(); if (!salesTable.validateWrite()) { throw Exception::Error; } salesTable.insert(); salesLine.SalesId = salesTable.SalesId; salesLine.ItemId = '1205'; salesLine...