Custom FormDatasource lookup in Ax

Description:- 
The following sample demonstrates how to add custom lookup to DataSource field on an AX form

public void lookup(FormControl _formControl, str _filterStr)
{
    SysTableLookup sysTableLookup; // systemclass to create //customlookup
    Query query;
    QueryBuildDataSource qbd;
    ;
    sysTableLookup = SysTableLookup::newParameters(tablenum(A_PurchaseOrder),_formcontrol);
    //Construct query on the table,
    //whose records you want to show as lookup.
    query = new Query();
    qbd = query.addDataSource(tablenum(A_PurchaseOrder));
    qbd.addRange(fieldnum(A_PurchaseOrder,Status)).value(SysQuery::value(enum2str(PO_Status::Close)));
    // add the fields to the lookup list
    sysTableLookup.addLookupfield(fieldnum(A_PurchaseOrder,Purchase_ID));
    sysTableLookup.addLookupfield(fieldnum(A_PurchaseOrder,Vender_Code));
    // pass the query as parameter
    // system will show the records in the lookup
    // as per your query
    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();
}

Related Posts

Previous
Next Post »

Thanks for comments.....