Lookups using X++ Code(without Ax Table or EDT relation). For that i override a String(Text) Control’ s lookup method.
public void lookup()
{
//super();
// Added by Vasanth Arivali
// Declaration
Query LookupQuery = new Query();
QueryBuildDataSource LookupQueryBuildDataSource;
QueryBuildRange LookupQueryBuildRange;
SysTableLookup CustomSysTableLookup = SysTableLookup::newParameters(tableNum(InventTable), this);
;
// Add fields that you want in Lookups
CustomSysTableLookup.addLookupField(fieldNum(InventTable, ItemId));
CustomSysTableLookup.addLookupField(fieldNum(InventTable,ItemName));
CustomSysTableLookup.addLookupField(fieldNum(InventTable,ItemGroupId));
CustomSysTableLookup.addLookupField(fieldNum(InventTable,ItemType));
// Add DataSource, Range and Value
LookupQueryBuildDataSource =
LookupQuery.addDataSource(tableNum(InventTable));
LookupQueryBuildRange=
LookupQueryBuildDataSource.addRange(fieldNum(InventTable,ItemVisibility));
LookupQueryBuildRange.value(queryValue(NOYESCOMBO::Yes));
// Execute the Query
CustomSysTableLookup.parmQuery(LookupQuery);
CustomSysTableLookup.performFormLookup();
}
public void lookup()
{
//super();
// Added by Vasanth Arivali
// Declaration
Query LookupQuery = new Query();
QueryBuildDataSource LookupQueryBuildDataSource;
QueryBuildRange LookupQueryBuildRange;
SysTableLookup CustomSysTableLookup = SysTableLookup::newParameters(tableNum(InventTable), this);
;
// Add fields that you want in Lookups
CustomSysTableLookup.addLookupField(fieldNum(InventTable, ItemId));
CustomSysTableLookup.addLookupField(fieldNum(InventTable,ItemName));
CustomSysTableLookup.addLookupField(fieldNum(InventTable,ItemGroupId));
CustomSysTableLookup.addLookupField(fieldNum(InventTable,ItemType));
// Add DataSource, Range and Value
LookupQueryBuildDataSource =
LookupQuery.addDataSource(tableNum(InventTable));
LookupQueryBuildRange=
LookupQueryBuildDataSource.addRange(fieldNum(InventTable,ItemVisibility));
LookupQueryBuildRange.value(queryValue(NOYESCOMBO::Yes));
// Execute the Query
CustomSysTableLookup.parmQuery(LookupQuery);
CustomSysTableLookup.performFormLookup();
}