28 February 2017

how to get different time zones time in AX 2012

static void timeZoneJob(Args _args)
{
    utcDateTime time1,time2;

    time1 = 2017-02-28T11:10:00;

    time2 = dateTimeUtil::applyTimeZoneOffset(time1,TimeZone::GMTPLUS0400YEREVAN); // manul time zone assign
    time2 = dateTimeUtil::applyTimeZoneOffset(time1,DateTimeUtil::getUserPreferredTimeZone()); // user based time zone assign  

    info(strFmt("%1",time2));

// AX 7

// DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone())
}

23 February 2017

How to get sales tax and Purch tax percentage in AX 2012

private TaxValue getTaxPercent(TaxGroup _taxGroup, TaxItemGroup _taxItemGroup)
{
    TaxGroupData    taxGroupData ;
    TaxOnItem       taxOnItem;
    TaxData         taxData;

    select firstonly TaxCode from taxGroupData
        index hint TaxGroupIdx
            where taxGroupData.TaxGroup == _taxGroup
            join taxOnItem
            where taxOnItem.TaxItemGroup == _taxItemGroup &&
                    taxOnItem.TaxCode == taxGroupData.TaxCode;

    select firstonly TaxValue from taxData where taxData.TaxCode == taxGroupData.TaxCode;
    return taxData.TaxValue;

}

17 February 2017

AX 2012 RecordInsertList || how to insert set of records in a single database call in AX 2012

RecordInsertList            insertRecords;
SalesTable                     salesTable;

insertRecords           = new RecordInsertList(tableNum(SalesTradeOverEstTmp)); // Define the Table to insert

while select salesTable
{
salesTradeOverEstTmp.salesId = salesTable.salesId;
salesTradeOverEstTmp.CustAccount salesTable.CustAccount;

insertRecords.add(salesTradeOverEstTmp);
}

insertRecords.insertDatabase();

AX 2012 SSRS DP class debugging code || How to debug an RDP class based SSRS report in AX 2012

static void SRSReportDebuggingJob(Args _args)
{
    CeSalesTradeOverEstTmp  salesTradeOverEstTmp; // temp table
    CeSalesTradeOverEstDP   ceSalesTradeOverEstDP = new CeSalesTradeOverEstDP(); //DP class
    CeSalesTradeOverEstContract ceSalesTradeOverEstContract = new CeSalesTradeOverEstContract();// contract class
   
    ceSalesTradeOverEstDP.parmDataContract(ceSalesTradeOverEstContract);
    ceSalesTradeOverEstDP.processReport();
    salesTradeOverEstTmp = ceSalesTradeOverEstDP.getSalesTradeOverEst();
   
    while select salesTradeOverEstTmp
    {
            info(salesTradeOverEstTmp.SalesId);
    }
   
}

Ledger Voucher creation Framework and x++ code to create ledger voucher

 Please click her for MS reference file Below is the out of the box example reference and code. SalesInvoiceJournalPostSubBill_Extension->...