lookup method in AX 2012

Hi All,
The following is the code for lookup method at control level in form.

public void lookup()

//add Query, QueryBuildDataSource, and QueryBuildRange objects. The following code example adds the classes you use to construct the query for the lookup form.

Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange queryBuildRange;

//Create an instance of SysTableLookup class. The following code example creates a lookup form for customers. Notice how this in the example represents the current form control.

SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(custTable), this);
sysTableLookup.addLookupField(fieldNum(CustTable, AccountNum));
sysTableLookup.addLookupField(fieldNum(CustTable, CustGroup));
queryBuildDataSource = query.addDataSource(tableNum(CustTable));

//Use a query to retrieve data for the lookup form. The following code example uses a range limit so that the lookup form lists customers who have the customer group of 40.

queryBuildRange = queryBuildDataSource.addRange(fieldNum(CustTable, CustGroup));

//Use the performFormLookup method to open the lookup form.


//When you override the lookup method, comment out the call to super. If you do not comment out the call to super, the standard lookup form might appear.



Right-click the form and then click Save. To see the lookup form, right-click the form and then click Open. Find the StringEdit control and then click the arrow to open the lookup form.

Thanks & Happy DaXing……..:)


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: