WINDOWS Live Search

To contact me for any clarifications regarding any posts / information, please mail me at arijit [dot] basu [at] gmail [dot] com


Saturday, August 4, 2007

Creating Sales Orders via X++

For beginner AX developers, I’m listing some codes which will help someone to create Sales Orders (Similar can be applied to PO) via X++ codes. This may be helpful to new Developers. [Level 200]

Some important Objects which are to be referred and understood are:
-Tables\SalesTable
-Tables\SalesLine
-Tables\InventDim
-Tables\CustTable
-Tables\InventTable
-Classes\SalesTableType {The InventType Hierarchy}

Sample Code [Very basic]

static void SalesOrderCreation(Args _args)
{
SalesTable salesTable;
NumberSeq NumberSeq;
SalesLine salesLine;
InventDim IDim;
;
ttsbegin;
NumberSeq = NumberSeq::newGetNumFromCode(SalesParameters::numRefSalesId).numberSequence);
//=======Table=======
salesTable.SalesId = NumberSeq.num();
salesTable.initValue();
salesTable.CustAccount = "4000"; //Enter Customer Acount
salesTable.initFromCustTable();
salesTable.InventLocationId = "GW";
salesTable.insert();
//========Line=======
salesLine.clear();
salesLine.SalesId = salesTable.SalesId;
salesLine.ItemId = "IS2082SAIL"; //Enter Item ID
IDim.InventColorId ="CU"; //Enter Item Dimensions
IDim.InventLocationId = "GW";
IDim = InventDim::findOrCreate(IDim);
salesLine.InventDimId = IDim.inventDimId;
salesLine.createLine(NoYes::Yes,
NoYes::Yes,
NoYes::Yes,
NoYes::Yes,
NoYes::Yes,
NoYes::Yes);
//===================
ttscommit;
Info(salesTable.SalesId);
}


The above code is very basic but will help you with the concepts and the same can be extended to create PO

Happy DAX-ing :)

1 comment:

Anonymous said...

But this code does not create the associated inventTrans record.