Question Status

Verified
Muhammad Aijaz asked a question on 7 Feb 2014 12:01 AM

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;

}

Muhammad Aijaz

Reply
Verified Answer
Muhammad Aijaz responded on 7 Feb 2014 12:03 AM

It's for help

Muhammad Aijaz

Reply
Verified Answer
Muhammad Aijaz responded on 7 Feb 2014 12:03 AM

It's for help

Muhammad Aijaz

Reply