AX 2009 Lookup methood help

Hi All,

I have created a table with 2 fields SalesId(EDT is SalesIdBase) and invoiceId(EDT is CustInvoiceId), and i have created a form and added these 2 fields, i am getting drop down for these 2 fields.

But i have a requirement such that when i select SalesId in 1st field then in 2nd field i.e InvoiceId only invoices related to these sales id should come in drop down.

Please let me know how can i write lookup on form or any other way?

Thanks in advance.

In order to create lookup override the lookup method for ‘InvoiceId’ field and to get the invoices for selected salesid. you can write a query to fetch it from ‘CustInvoiceJour’.

dummy Syntax:

sysTableLookup tablelookup;

Query q = new query();


q.addDatasource(tablenum(custinvoicejour)).addrange(fieldnum(custinvoicejour, salesid)).value(queryvalue(SpecifiedSalesId));



Hi Vishal,

Thank you for your reply, your sample code helped me to finish my task, and the code which i have written is

ublic void lookup(FormControl _formControl, str _filterStr)

SysTableLookup sysTableLookup; // systemclass to create //customlookup
Query query;
QueryBuildDataSource qbd;

sysTableLookup = SysTableLookup::newParameters(

// Construct query on the table,
// whose records you want to show as lookup.
query = new Query();
qbd = query.addDataSource(tablenum(CustInvoiceJour));
// qbd.addRange(fieldnum(InventTable,ItemType)).value(SysQuery::value(enum2str
// (ItemType::Item)));
qbd.addrange(fieldnum(CustInvoiceJour, SalesId)).value(queryvalue(ADMMISalesCustPlace.SalesId));

// add the fields to the lookup list

// pass the query as parameter
// system will show the records in the lookup
// as per your query