How to Bind Custom LookUp Using Table Method in Ax 2012

Description:- 
In this article we will Create custom lookup and bind using table method. First of all we will create New Method in table and using lookup method we will call table method in lookup.

Create New Method in Table Using SysTableLookup and Add Lookup fields what fields you want to show in Lookup. After Override Lookup method of that Controls and Call Created Table method in Controls lookup method.

Create method in table

public static void lookupFields(FormControl _formControl)
{
    Query                   query = newQuery();
    QueryBuildDataSource    queryBuildDataSource;
    SysTableLookup          sysTableLookup;
    ;
    changecompany (curext())
    {
        query.addDataSource(tablenum(A_PurchaseOrder));
        sysTableLookup = SysTableLookup::newParameters(tablenum(A_PurchaseOrder), _formControl);
        sysTableLookup.addLookupfield(fieldnum(A_PurchaseOrder, Purchase_ID),true);
        sysTableLookup.addLookupfield(fieldnum(A_PurchaseOrder, Vender_Code));
        sysTableLookup.addLookupfield(fieldnum(A_PurchaseOrder, Status));
        sysTableLookup.addLookupfield(fieldnum(A_PurchaseOrder, Purchase_Date));
        sysTableLookup.addLookupfield(fieldnum(A_PurchaseOrder, Purchase_Amount));
        sysTableLookup.parmQuery(query);
        sysTableLookup.performFormLookup();
    }
}

Now Go to That Form Control and Generate Lookup Override Method.

public void lookup()
{
    super();
    A_PurchaseOrder::lookupFields(this);
}

Output:-

Related Posts

Previous
Next Post »

Thanks for comments.....