Blog Archives

How to create sales order through code

I found few good sample code for creating sales order in a book and I was able to compile a code for posting sales order invoice. I thought I should share on my blog. It might be useful for some one.

Code for creating Sales order

SalesTableType and SalesLinetype. Insert() should be called for creating the sales order. Example is as follows. I am currently looking for code that can contains example code of creating invoice from scratch. I will send you the code in an hour.

static void createSalesTable(CustAccount _custAccount)


SalesTable salesTable;

NumberSeq NumberSeq;


NumberSeq =



salesTable.SalesId = NumberSeq.num();


salesTable.CustAccount = _custAccount;




Example: Create a Sales Line

static void createSalesLine(SalesId _salesId, ItemId _itemId)


SalesLine salesLine;



salesLine.SalesId = _salesId;

salesLine.ItemId = _itemId;

salesLine.createLine(NoYes::Yes, // Validate

NoYes::Yes, // initFromSalesTable

NoYes::Yes, // initFromInventTable

NoYes::Yes, // calcInventQty

NoYes::Yes, // searchMarkup

NoYes::Yes); // searchPrice


Code for posting Sales order Invoice

static void createSalesOrder(Args _args)


SalesFormLetter formLetterObj;

formLetterObj = SalesFormLetter::construct(DocumentStatus::Invoice);



%d bloggers like this: