Friday, 25 November 2016

Query lookup in ax 2012 using x++ code


Query lookup in ax 2012 using x++ code


public void lookup()
{
    Query                   query;
    QueryBuildDataSource    vendTable;
    QueryBuildRange         range;
    SysTableLookup          sysTableLookup;

    query               = new Query();
    vendTable           = query.addDataSource(tableNum(VendTable));

    range               = vendTable.addRange(fieldNum(VendTable, AccountNum));
    range.value("INMF-000001");//here we can pass range

    sysTableLookup = SysTableLookup::newParameters(tableNum(VendTable), this);

    //here true is used for getting accountNum only.
    sysTableLookup.addLookupfield(fieldNum(VendTable, AccountNum),true);

   //here we can get the method like this way.
    sysTableLookup.addLookupMethod(tableMethodStr(VendTable, Name));
    
    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();
}

No comments:

Post a Comment