public void lookup()
{
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange qbrForAccount;
SysTableLookup sysTableLookup;
String255 dimType;
DimensionAttribute dimensionAttribute;
DimensionAttributeDirCategory dimAttributeDirCategory;
;
sysTableLookup = SysTableLookup::newParameters(tableNum(OMOperatingUnit),this,true);
sysTableLookup.parmUseLookupValue(false);
sysTableLookup.addLookupfield(fieldNum(OMOperatingUnit, OMOperatingUnitNumber));
sysTableLookup.addLookupfield(fieldNum(OMOperatingUnit, Name));
queryBuildDataSource = query.addDataSource(tableNum(OMOperatingUnit));
queryBuildDataSource.addSortField(fieldnum(OMOperatingUnit,OMOperatingUnitNumber));
queryBuildDataSource.addRange(fieldNum(OMOperatingUnit, OMOperatingUnitType)).value(int2str(any2int(OMOperatingUnitType::OMBusinessUnit)));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
====================================================================
http://ax2009developer.blogspot.in/2014/02/how-create-customize-look-up-for.html
public void lookup()
{
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange qbrForAccount;
SysTableLookup sysTableLookup;
DimType dimType;
DimensionAttribute dimensionAttribute;
DimensionAttributeDirCategory dimAttributeDirCategory;
;
dimType = str2enum(dimType,FilterGroup_Type.valueStr());
switch(dimType)
{
case DimType::Department:
sysTableLookup = SysTableLookup::newParameters(tableNum(OMOperatingUnit),this,true);
sysTableLookup.parmUseLookupValue(false);
sysTableLookup.addLookupfield(fieldNum(OMOperatingUnit, OMOperatingUnitNumber));
sysTableLookup.addLookupfield(fieldNum(OMOperatingUnit, Name));
queryBuildDataSource = query.addDataSource(tableNum(OMOperatingUnit));
queryBuildDataSource.addSortField(fieldnum(OMOperatingUnit,OMOperatingUnitNumber));
queryBuildDataSource.addRange(fieldNum(OMOperatingUnit, OMOperatingUnitType)).value(int2str(any2int(OMOperatingUnitType::OMDepartment)));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
break;
case DimType::BusinessUnit:
sysTableLookup = SysTableLookup::newParameters(tableNum(OMOperatingUnit),this,true);
sysTableLookup.parmUseLookupValue(false);
sysTableLookup.addLookupfield(fieldNum(OMOperatingUnit, OMOperatingUnitNumber));
sysTableLookup.addLookupfield(fieldNum(OMOperatingUnit, Name));
queryBuildDataSource = query.addDataSource(tableNum(OMOperatingUnit));
queryBuildDataSource.addSortField(fieldnum(OMOperatingUnit,OMOperatingUnitNumber));
queryBuildDataSource.addRange(fieldNum(OMOperatingUnit, OMOperatingUnitType)).value(int2str(any2int(OMOperatingUnitType::OMBusinessUnit)));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
break;
case DimType::CostCenter:
sysTableLookup = SysTableLookup::newParameters(tableNum(OMOperatingUnit),this,true);
sysTableLookup.parmUseLookupValue(false);
sysTableLookup.addLookupfield(fieldNum(OMOperatingUnit, OMOperatingUnitNumber));
sysTableLookup.addLookupfield(fieldNum(OMOperatingUnit, Name));
queryBuildDataSource = query.addDataSource(tableNum(OMOperatingUnit));
queryBuildDataSource.addSortField(fieldnum(OMOperatingUnit,OMOperatingUnitNumber));
queryBuildDataSource.addRange(fieldNum(OMOperatingUnit, OMOperatingUnitType)).value(int2str(any2int(OMOperatingUnitType::OMCostCenter)));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
break;
case DimType::Project:
dimensionAttribute = DimensionAttribute::findByName("Project");
if (dimensionAttribute.Type == DimensionAttributeType::CustomList)
{
select firstonly DirCategory from dimAttributeDirCategory where dimAttributeDirCategory.DimensionAttribute == dimensionAttribute.RecId;
sysTableLookup = SysTableLookup::newParameters(tableNum(DimensionFinancialTag), this,true);
sysTableLookup.addLookupfield(fieldNum(DimensionFinancialTag, Value));
sysTableLookup.addLookupfield(fieldNum(DimensionFinancialTag, Description));
query = new Query();
query.addDataSource(tableNum(DimensionFinancialTag)).addRange(fieldNum(DimensionFinancialTag, FinancialTagCategory)).value(queryValue(dimAttributeDirCategory.DirCategory));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
break;
case DimType::Account:
sysTableLookup = SysTableLookup::newParameters(tableNum(MainAccount),this,true);
sysTableLookup.parmUseLookupValue(false);
sysTableLookup.addLookupfield(fieldNum(MainAccount, MainAccountId));
sysTableLookup.addLookupMethod(tableMethodStr(MainAccount, localizedName));
sysTableLookup.addLookupfield(fieldNum(MainAccount, Type));
queryBuildDataSource = query.addDataSource(tableNum(MainAccount));
qbrForAccount = queryBuildDataSource.addRange(fieldNum(MainAccount,LedgerChartOfAccounts));
qbrForAccount.value(queryValue(Ledger::current()));
queryBuildDataSource.addSortField(fieldnum(MainAccount,MainAccountId));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
break;
{
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange qbrForAccount;
SysTableLookup sysTableLookup;
String255 dimType;
DimensionAttribute dimensionAttribute;
DimensionAttributeDirCategory dimAttributeDirCategory;
;
sysTableLookup = SysTableLookup::newParameters(tableNum(OMOperatingUnit),this,true);
sysTableLookup.parmUseLookupValue(false);
sysTableLookup.addLookupfield(fieldNum(OMOperatingUnit, OMOperatingUnitNumber));
sysTableLookup.addLookupfield(fieldNum(OMOperatingUnit, Name));
queryBuildDataSource = query.addDataSource(tableNum(OMOperatingUnit));
queryBuildDataSource.addSortField(fieldnum(OMOperatingUnit,OMOperatingUnitNumber));
queryBuildDataSource.addRange(fieldNum(OMOperatingUnit, OMOperatingUnitType)).value(int2str(any2int(OMOperatingUnitType::OMBusinessUnit)));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
====================================================================
http://ax2009developer.blogspot.in/2014/02/how-create-customize-look-up-for.html
How Create Customize Look up for Financial Dimension in Ax2012
Following lookup help for dimension filtration according to enum value over here
DimType is customized filed which contain Department, CostCenter, Project, Account and BusinessUnit.
Select any one option then use following code of lookup for filter public void lookup()
{
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange qbrForAccount;
SysTableLookup sysTableLookup;
DimType dimType;
DimensionAttribute dimensionAttribute;
DimensionAttributeDirCategory dimAttributeDirCategory;
;
dimType = str2enum(dimType,FilterGroup_Type.valueStr());
switch(dimType)
{
case DimType::Department:
sysTableLookup = SysTableLookup::newParameters(tableNum(OMOperatingUnit),this,true);
sysTableLookup.parmUseLookupValue(false);
sysTableLookup.addLookupfield(fieldNum(OMOperatingUnit, OMOperatingUnitNumber));
sysTableLookup.addLookupfield(fieldNum(OMOperatingUnit, Name));
queryBuildDataSource = query.addDataSource(tableNum(OMOperatingUnit));
queryBuildDataSource.addSortField(fieldnum(OMOperatingUnit,OMOperatingUnitNumber));
queryBuildDataSource.addRange(fieldNum(OMOperatingUnit, OMOperatingUnitType)).value(int2str(any2int(OMOperatingUnitType::OMDepartment)));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
break;
case DimType::BusinessUnit:
sysTableLookup = SysTableLookup::newParameters(tableNum(OMOperatingUnit),this,true);
sysTableLookup.parmUseLookupValue(false);
sysTableLookup.addLookupfield(fieldNum(OMOperatingUnit, OMOperatingUnitNumber));
sysTableLookup.addLookupfield(fieldNum(OMOperatingUnit, Name));
queryBuildDataSource = query.addDataSource(tableNum(OMOperatingUnit));
queryBuildDataSource.addSortField(fieldnum(OMOperatingUnit,OMOperatingUnitNumber));
queryBuildDataSource.addRange(fieldNum(OMOperatingUnit, OMOperatingUnitType)).value(int2str(any2int(OMOperatingUnitType::OMBusinessUnit)));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
break;
case DimType::CostCenter:
sysTableLookup = SysTableLookup::newParameters(tableNum(OMOperatingUnit),this,true);
sysTableLookup.parmUseLookupValue(false);
sysTableLookup.addLookupfield(fieldNum(OMOperatingUnit, OMOperatingUnitNumber));
sysTableLookup.addLookupfield(fieldNum(OMOperatingUnit, Name));
queryBuildDataSource = query.addDataSource(tableNum(OMOperatingUnit));
queryBuildDataSource.addSortField(fieldnum(OMOperatingUnit,OMOperatingUnitNumber));
queryBuildDataSource.addRange(fieldNum(OMOperatingUnit, OMOperatingUnitType)).value(int2str(any2int(OMOperatingUnitType::OMCostCenter)));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
break;
case DimType::Project:
dimensionAttribute = DimensionAttribute::findByName("Project");
if (dimensionAttribute.Type == DimensionAttributeType::CustomList)
{
select firstonly DirCategory from dimAttributeDirCategory where dimAttributeDirCategory.DimensionAttribute == dimensionAttribute.RecId;
sysTableLookup = SysTableLookup::newParameters(tableNum(DimensionFinancialTag), this,true);
sysTableLookup.addLookupfield(fieldNum(DimensionFinancialTag, Value));
sysTableLookup.addLookupfield(fieldNum(DimensionFinancialTag, Description));
query = new Query();
query.addDataSource(tableNum(DimensionFinancialTag)).addRange(fieldNum(DimensionFinancialTag, FinancialTagCategory)).value(queryValue(dimAttributeDirCategory.DirCategory));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
break;
case DimType::Account:
sysTableLookup = SysTableLookup::newParameters(tableNum(MainAccount),this,true);
sysTableLookup.parmUseLookupValue(false);
sysTableLookup.addLookupfield(fieldNum(MainAccount, MainAccountId));
sysTableLookup.addLookupMethod(tableMethodStr(MainAccount, localizedName));
sysTableLookup.addLookupfield(fieldNum(MainAccount, Type));
queryBuildDataSource = query.addDataSource(tableNum(MainAccount));
qbrForAccount = queryBuildDataSource.addRange(fieldNum(MainAccount,LedgerChartOfAccounts));
qbrForAccount.value(queryValue(Ledger::current()));
queryBuildDataSource.addSortField(fieldnum(MainAccount,MainAccountId));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
break;
}
No comments:
Post a Comment