Dimension Look up in AX 2012


SysTableLookup sysTableLookup;
QueryBuildDataSource queryBuildDataSource,queryBuildDataSource1;
Query query;
QueryBuildRange queryRangePhysical,queryRangeTechnical;
DimensionAttribute dimAttr;

select firstonly recid from dimAttr where dimAttr.Name == “Dimension Name(Department or Costcenter,…etc)”
if (dimAttr)
{
sysTableLookup = SysTableLookup::newParameters(tablenum(DimensionFinancialTag), this);

sysTableLookup.addLookupfield(fieldnum(DimensionFinancialTag, value),true);
sysTableLookup.addLookupfield(fieldnum(DimensionFinancialTag, Description),false);
query = new Query();

queryBuildDataSource = query.addDataSource(tablenum(DimensionFinancialTag));
queryBuildDataSource1 = queryBuildDataSource.addDataSource(tableNum(DimensionAttributeDirCategory));
queryBuildDataSource1.relations(true);
queryBuildDataSource1.joinMode(JoinMode::InnerJoin);
queryBuildDataSource1.addLink(fieldnum(DimensionFinancialTag, FinancialTagCategory), fieldnum(DimensionAttributeDirCategory, DirCategory));

queryBuildDataSource1.addRange(fieldnum(DimensionAttributeDirCategory,DimensionAttribute)).value(queryValue(dimAttr.RecId));
sysTableLookup.parmQuery(query);

sysTableLookup.performFormLookup();
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s