Alfasith AX

Alfasith AX
اللَّهُمَّ انْفَعْنِي بِمَا عَلَّمْتَنِي، وَعَلِّمْنِي مَا يَنْفَعُنِي، وَزِدْنِي عِلْمًا

Monday, March 5, 2018

Joining a table in datasource without adding the table in to the form data source in AX 2012

Hi,

In my case I needs to add the purchTable as range but I dont want to add the table in that form datasource.

I added the below code in the PurchLine init().

public void init()
{
    Query                   query = new Query();
    QueryBuildDataSource    purchTableDS,purchLineDS;
    QueryBuildRange         activityNum,purchStatus;
    ProjBudgetLine          projBudgetLine;
    Query                   queryDB;
    QueryBuildDataSource        qbdsPurchLine;
    QueryBuildDataSource        qbdsPurchTable;
    super();
    projBudgetLine  =   element.args().record();
    qbdsPurchLine = this.query().dataSourceTable(tableNum(PurchLine));
    qbdsPurchLine.addRange(fieldnum(PurchLine, ActivityNumber)).value(queryvalue(projBudgetLine.ActivityNumber));

    qbdsPurchTable = qbdsPurchLine.addDataSource(tableNum(PurchTable));
    qbdsPurchTable.addLink(fieldNum(PurchTable, PurchId), fieldNum(PurchLine, PurchId));
    qbdsPurchTable.addRange(fieldnum(PurchTable, DocumentStatus)).value(queryValue(DocumentStatus::PurchaseOrder));

}

Get purchase Lines Sales tax in AX 2012

    TaxJournalTrans      taxJournal;

    select SourceTaxAmountCur,TaxAmount from taxJournal where taxJournal.TransRecId  == vendPurchOrderJour.RecId
                        &&  taxJournal.TransTableId     == tableNum(vendPurchOrderJour)
                        &&  taxJournal.InventTransId    == purchLineAllVersions.InventTransId;
    if(vendFormletterParameters.TaxSpecPrintLevel == TaxSpecPrintLevel::Currency)
    {
        purchPurchaseOrderTmp.VAT = taxJournal.SourceTaxAmountCur;
    }
    else if(vendFormletterParameters.TaxSpecPrintLevel == TaxSpecPrintLevel::CurrencyMST)
    {
        purchPurchaseOrderTmp.VAT = taxJournal.TaxAmount;
    }
    else
        purchPurchaseOrderTmp.VAT = 0.0;

Regards,

How find size of recordsortedlist in D365/AX 2012

Hi, This is the continuity of the previous article where we are now getting the size of recordsortedlist . if(recordsortedlist.len() >1) ...