Get Sales Order Totals using X++


We can make use of standard class SalesTotals to get the Totals subform related fields data through X++. SalesTotals returns a container with lot of fields in it, Some of them i have listed below.



static void SalesOrderTotal(Args _args)
{
    SalesTotals     salesTotals;
    SalesTable      salesTable;
    container       displayFields;
    str             totalTax,  amountInclTax, amountWithoutTaxTxt;
    AmountMST       amountWithoutTax;
    

    salesTable = salesTable::find('S000076');
    salesTotals  =  SalesTotals::construct(salesTable, salesUpdate::All);
    salesTotals.calc();
    displayFields =  salesTotals.displayFieldsCurrency(salesTotals.currencyCode());

    amountWithoutTaxTxt     = conpeek(displayFields, TradeTotals::posBalance());
    amountWithoutTax        = str2num(amountWithoutTaxTxt);
    amountInclTax           = conpeek(displayFields, TradeTotals::posTotalAmount());
    totalTax                = conpeek(displayFields,TradeTotals::posTaxTotal());
}

Comments

Popular posts from this blog

Sales order invoice posting using X++ with custom SalesParmLine fields

Create a custom lookup with multiple data sources on form using X++

SalesTable2Line custom field update prompt on Sales order in AX 2012