static DimensionDefault findDefaultDimension(str _businessUnit, str _costCentre, str _jurisdiction, str _subscriberType)
{
Struct struct = new Struct();
container defDimensionCon;
DimensionDefault dimensionDefault;
DimensionAttributeSetItem dimAttrSetItem;
DimensionAttribute dimAttribute;
int i;
//Read required dimensions
while select Name, BackingEntityType from dimAttribute
where dimAttribute.BackingEntityType == tableNum(DimensionFinancialTag) &&
dimAttribute.Type != DimensionAttributeType::DynamicAccount
join dimAttrSetItem
where dimAttrSetItem.DimensionAttribute == dimAttribute.RecId &&
dimAttrSetItem.DimensionAttributeSet == DimensionCache::getDimensionAttributeSetForLedger()
{
//Add the Dimension name and value to struct
if (_businessUnit && dimAttribute.BackingEntityType == tableNum(DimensionFinancialTag) && dimAttribute.Name == 'BusinessUnit')
{
struct.add(dimAttribute.Name, _businessUnit);
}
if (_costCentre && dimAttribute.BackingEntityType == tableNum(DimensionFinancialTag) && dimAttribute.Name == 'CostCentre')
{
struct.add(dimAttribute.Name, _costCentre);
}
if (_jurisdiction && dimAttribute.BackingEntityType == tableNum(DimensionFinancialTag) && dimAttribute.Name == 'Jurisdiction')
{
struct.add(dimAttribute.Name, _jurisdiction);
}
if (_subscriberType && dimAttribute.BackingEntityType == tableNum(DimensionFinancialTag) && dimAttribute.Name == 'SubscriberType')
{
struct.add(dimAttribute.Name, _subscriberType);
}
}
defDimensionCon += struct.fields();
for (i = 1; i <= struct.fields(); i++)
{
defDimensionCon += struct.fieldName(i);
defDimensionCon += struct.valueIndex(i);
}
if (struct.fields())
{
//Get the DimensionAttributeValueSet RecId
dimensionDefault = AxdDimensionUtil::getDimensionAttributeValueSetId(defDimensionCon);
}
return dimensionDefault;
}
Wednesday, July 23, 2014
Setting Default Dimension using code in AX 2012
The following method can be used to set the default dimension e.g. on CustTable when importing data via X++
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment