Tuesday, 28 June 2016

Create new sales order in AX through code

static void createSalesOrder(Args _args)
{
    SalesTable salesTable;
    SalesLine salesLine;
    NumberSeq NumberSeq;
    ;
    NumberSeq = NumberSeq::newGetNum(SalesParameters::numRefSalesId());
    salesTable.SalesId = NumberSeq.num();
    salesTable.initValue();
    salesTable.CustAccount = '####';
    salesTable.initFromCustTable();
    salesTable.insert();

    salesLine.clear();
    salesLine.SalesId = salesTable.SalesId;
    salesLine.ItemId = 'P0001';
    salesLine.createLine(NoYes::Yes, // Validate
    NoYes::Yes, // initFromSalesTable
    NoYes::Yes, // initFromInventTable
    NoYes::Yes, // calcInventQty
    NoYes::Yes, // searchMarkup
    NoYes::Yes); // searchPrice

    info(strFmt('Sales Order %1 created', salesTable.SalesId));

}

No comments:

Post a comment