Tuesday, January 24, 2023

Add Lookup Method for Dimension fields using x++

 Add Lookup Method for Dimension fields using x++.


Division Lookup:

   #define.DimensionName("Division")  
   Query          query;  
   QueryBuildDataSource  qbds,qbds1;  
   SysTableLookup     sysTableLookup;  
   DimensionAttribute   dimAttr;  
     
   dimAttr = DimensionAttribute::findByName(#DimensionName);  
   sysTableLookup = SysTableLookup::newParameters(tablenum(DimensionFinancialTag),divisionCodeLookup);  
   sysTableLookup.addLookupfield(fieldnum(DimensionFinancialTag, Value));  
   sysTableLookup.addLookupfield(fieldNum(DimensionFinancialTag, Description)); 
   
   query = new Query();  
   qbds = query.addDataSource(tableNum(DimensionFinancialTag));  
   qbds1 = qbds.addDataSource(tableNum(DimensionAttributeDirCategory));  
   qbds1.addLink(fieldNum(DimensionFinancialTag,FinancialTagCategory),fieldnum(DimensionAttributeDirCategory,RecId));  
   qbds1.addRange(fieldNum(DimensionAttributeDirCategory, DimensionAttribute)).value(queryvalue(dimAttr.recid)); 
   
   sysTableLookup.parmQuery(query);  
   sysTableLookup.parmUseLookupValue(False);  
   sysTableLookup.performFormLookup(); 


Branch Lookup:

#define.DimensionName("Branch")  
Query          query;  
QueryBuildDataSource  qbds,qbds1;  
SysTableLookup     sysTableLookup;  
DimensionAttribute   dimAttr;  

dimAttr = DimensionAttribute::findByName(#DimensionName);  
sysTableLookup = SysTableLookup::newParameters(tablenum(OMOperatingUnit),branchCodeLookup);  
sysTableLookup.addLookupfield(fieldnum(OMOperatingUnit, OmoperatingunitNumber));  
sysTableLookup.addLookupfield(fieldNum(OMOperatingUnit,Name));  

query = new Query();  
qbds = query.addDataSource(tableNum(OMOperatingUnit));  
qbds.addRange(fieldNum(OMOperatingUnit, OMOperatingUnitType)).value(queryvalue(OMOperatingUnitType::OMBusinessUnit)); 

sysTableLookup.parmQuery(query);  
sysTableLookup.parmUseLookupValue(False);  
sysTableLookup.performFormLookup();


Keep Daxing!!

No comments:

Post a Comment