How To add Method Value in Lookup in AX2012?

Hi,

I want to add ItemGroupId,ProductName fields in ItemId Lookup.

In Standard code is there in LookupItem metho in InventTable

But It is Showing only ItemId,SearchName,ItemType,Product But It is not showing ItemGroupId,DefaultProductName.

The standard code in LookupItem:

///

/// Provides a lookup for the InventTable table.

///

///

/// The form string control object with which to perform the lookup.

///

public client static void lookupItem(FormStringControl _ctrl)

{

SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(InventTable),_ctrl);

Query query = new Query();

QueryBuildDataSource queryBuildDataSource = query.addDataSource(tableNum(InventTable));

sysTableLookup.addLookupfield(fieldNum(InventTable,ItemId));

sysTableLookup.addLookupMethod(tableMethodStr(InventTable,itemGroupId));

sysTableLookup.addLookupMethod(tableMethodStr(InventTable,defaultProductName));

sysTableLookup.addLookupfield(fieldNum(InventTable,NameAlias));

sysTableLookup.addLookupfield(fieldNum(InventTable,ItemType));

sysTableLookup.addSelectionField(fieldNum(InventTable,Product));

sysTableLookup.parmQuery(query);

sysTableLookup.performFormLookup();

}

Add LookUpMethod values or not showing in ItemId Lookup

Pls Help me How add these 2 fields in Lookup.

Thanks,

Balu

Hi Balu,

I tried at my end its working fine , I think you need to do changes on below line

SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(InventTable),this);

use this keyword instead of _ctrl

I tried it on form field level as below.

public void lookup()

{

SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(InventTable),this);

Query query = new Query();

QueryBuildDataSource queryBuildDataSource = query.addDataSource(tableNum(InventTable));

sysTableLookup.addLookupfield(fieldNum(InventTable,ItemId));

sysTableLookup.addLookupMethod(tableMethodStr(InventTable,itemGroupId));

sysTableLookup.addLookupMethod(tableMethodStr(InventTable,defaultProductName));

sysTableLookup.addLookupfield(fieldNum(InventTable,NameAlias));

sysTableLookup.addLookupfield(fieldNum(InventTable,ItemType));

sysTableLookup.addSelectionField(fieldNum(InventTable,Product));

sysTableLookup.parmQuery(query);

sysTableLookup.performFormLookup();

}

Hi,

I solve this issue.

In InventTable AutoLookup fieldgroup I add those fields

It:s working

Thanks

Balu

i have a problem in populating the lookup,i created a lookup for temorary table ,i call that lookup in field-> lookup method,whenever i clicking the dropdown box of that control,it generating the data again and again.how to resolve it,

look at this website.

http://axdeveloper.wordpress.com/2014/08/04/lesson60-lookup-5-sysmultitablelookup/#more-1741

if you are writing the lookup method ,then comment the super method .

Hi Balu,

There is a simple way to fulfill your requirement…

@data source field node level override lookup method as

//Super(…); comment this super command…

InventTable::lookupItem(_formControl);//calling base lookup method from InventTable…

No need to write any additional lookup methods…

Thanking you