Wednesday 10 August 2016


to uncheck checkbox when other checkbox is checked, vice-versa AX 2012
in a dialog
put code in UIbulder class.

public void postRun()
{
    super();

    dialog.dialogForm().formRun().controlMethodOverload(false);

    noRouteVersion.registerOverrideMethod(methodStr(FormStringControl, modified), methodStr(AMPHRouteExceptionReportUIBuilder, noRouteVersionModified), this);
}
-----
public boolean noRouteVersionModified(FormStringControl _control)
{
    boolean             ret;
    LedgerPeriodCode    ledgerPeriodCode;

    ret = _control.modified();

    if (ret)
    {
-code / condition-
    }

return ret;

}

Monday 9 May 2016

Using Change Company in Ax 2009


To get data from different companies, use

change company:

changecompany(''C') // c: company name
    {
   // code;
    }
or
use queryframe work and add the company range as:

 qr.allowCrossCompany(true);
    qr.query().addCompanyRange('A');
    qr.query().addCompanyRange(''B'');

for reference find the below code.
here I am filtering the PO which are invoice and received and also based on VendGroup
and fetching the data from purchline.
...................................................................................................................................................
public boolean fetch()
{

    QueryBuildDataSource qbds,qbds1;
    Query q = new Query();
    QueryBuildRange qbr,qbr1,qbr2;
    QueryRun qr;
    container conCompanies = [ ''A", ''B'' ]; // you can assign the selected company
    ;

   changecompany(''C'')
    {
   // code;
    }

   //or

    qbds = q.addDataSource(tablenum(PurchTable));
   qbds1 = qbds.addDataSource(tablenum(purchLine));
    qbds.joinMode(joinmode::InnerJoin);
    qbds1.relations(true);

    qbr1 = q.dataSourceTable(tablenum(PurchTable)).addRange(fieldnum(PurchTable,VendGroup));
    qbr1.value("HIRING");


    qbr2 =  q.dataSourceTable(tablenum(PurchTable)).addRange(fieldnum(PurchTable,DeliveryDate));
    qbr2.value(queryValue(fromDate)+ '..'+ queryValue(toDate));

    qbr = q.dataSourceTable(tablenum(PurchTable)).addRange(fieldnum(PurchTable,PurchStatus));
   //qbr.value(enum2str((PurchStatus::Received)  || (PurchStatus::Invoiced )));
       qbr.value(strFmt('%1,%2', PurchStatus::Received,PurchStatus::Invoiced));

    qr = new QueryRun(q);
    qr.allowCrossCompany(true);
    qr.query().addCompanyRange('A');
    qr.query().addCompanyRange(''B'');

    while(qr.next())
    {
        purchLine = qr.getNo(2);
       element.send(purchLine);

    }


}
    return true;
}