Create Lookup code on dimension field ConfigId in x++
We can create lookup of configuration in x++ on base of ItemId as follows;
public void lookup()
{
FormRun callerForm = element.args().caller();
InventTable localinventable;
str articleId = '1234'
select firstonly localinventable where localinventable.ItemId == articleId;
Query query = new Query();
QueryBuildDataSource queryBuildDataSource, QueryBuildDataSource1;
QueryBuildRange queryBuildRange, queryBuildRange1;
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(EcoResConfiguration ), this);
queryBuildDataSource = query.addDataSource(tableNum(EcoResConfiguration));
QueryBuildDataSource1 = queryBuildDataSource.addDataSource(tableNum(EcoResProductMasterConfiguration ));
QueryBuildDataSource1.addLink(fieldNum(EcoResConfiguration, RecId), fieldNum(EcoResProductMasterConfiguration, Configuration));
QueryBuildDataSource1.joinMode(JoinMode::InnerJoin);
QueryBuildDataSource1.addRange(fieldNum(EcoResProductMasterConfiguration, ConfigProductMaster)).value(SysQuery::value(localinventable.Product));
SysTableLookup.addLookupfield(fieldNum(EcoResConfiguration, Name));
sysTableLookup.parmQuery(query);
sysTableLookup.parmUseLookupValue(false);
sysTableLookup.performFormLookup();
}
Comments