How to fetch method value into lookup in ax 2012

Hi all,

I want to show item name into look up .

in ax2009 ItemName fields is there but in ax 2012 its removed and added into method e.g name()

my requirement is i need to fetch name() method value as a lookup along with item id.

note : name() is static method.

at the time of compiling look up there is no error ,but while running look up its throwing an error “Type void is not supported in this type of lookups” ,

the code which i written as below.

public void lookup()
{
//super();

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

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

sysTableLookup.addLookupField(fieldNum(InventTable, ItemId),true);
sysTableLookup.addLookupMethod(‘name’);

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

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

queryBuildRange = queryBuildDataSource.addRange(fieldNum(InventTable, rmsInsurancePercentage),true);

queryBuildRange.value(’>0’);

sysTableLookup.parmQuery(query);

sysTableLookup.performFormLookup();
}

It will appreciated if some can help me to resolved this.

Hi Nitin,

Can you try the code like this please?

sysTableLookup.addLookupMethod(tablemethodstr(InventTable, Name));

Thanks for quick reply Sevin.

but its now working , it is giving compilation error e.g The class InventTable dose not contain this method.

name is a static method cannot be used like this.

Have a look at \Data Dictionary\Tables\InventTable\Methods\lookupItem which uses defaultProductName method

Thanks for reply Kranthi.

I tried by your suggested way but still its not getting output . lookup is showing Product name with blank value.

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

I am not sure but i think need to pass parameters.

Product need to be added as selection field. sysTableLookup.addSelectionField(

fieldNum(InventTable,Product));

Thanks Kranthi you suggestion worked my lookup issue get resolved.

I was using ItemId instead of Product and that’s why i was not getting it. because product is new concept in Ax2012 which was not into earlier version.

Product is single, unified identification of a product throughout the entire organization. and Item is legal entity specific.