DAXSPOT

Tuesday, May 21, 2019

Lookup in form string control

Hi,
Below is an example of the lookup in form string control.
First Go to the string control and override the lookup method, then copy the below code. Change the code as per your requirement.
public void lookup()
{
    Query query;
    QueryBuildDataSource datasourceModule;
    QueryBuildDataSource datasourceLanguage;
    QueryBuildRange rangeElementType;
    QueryBuildRange rangeModuleId;
    SysTableLookup sysTableLookup;
 
    query = new Query();
//Add table in Query build datasource
    datasourceLanguage = query.addDataSource(tableNum(SalesTable));
//pass a range, here i need salesOrder with Backorder status only   
    datasourceLanguage.addRange(
        fieldNum(SalesTable, SalesStatus)).value(queryValue(SalesStatus::BackOrder));
//add the lookup table
    sysTableLookup = SysTableLookup::newParameters(tableNum(SalesTable), this);

//Add which field to show in lookup
    sysTableLookup.addLookupfield(fieldNum(SalesTable, SalesId));

//add the above build query to the lookup Query
    sysTableLookup.parmQuery(query);

//at last perform the lookup.
    sysTableLookup.performFormLookup();

}

No comments:

Post a Comment

How to execute SQL directly form Dynamics AX X++

How to execute Sql directly form Dynamics AX X++ Reference by : alirazazaidi Dynamics Ax provide many other ways to communicate with databas...