How to get Default Dimension value for the Record in D365FO using x++.
Way 1: by class
public DimensionValue getDimensonValue(LedgerDimensionValueSet _defaultDimension)
{
DimensionAttributeValueSetStorage dimensionAttributeValueSetStorage;
DimensionAttribute dimensionAttribute;
DimensionValue dimensionValue;
;
#define.DimensionName("CostCenter")// 'DimensionName'
dimensionAttributeValueSetStorage = dimensionAttributeValueSetStorage::find(_defaultDimension);
dimensionAttribute = dimensionAttribute::findbyname(#DimensionName);
dimensionValue = dimensionAttributeValueSetStorage.getDisplayValueByDimensionAttribute(
dimensionAttribute.recId);
return dimensionValue;
}
Way 2: by View
Public DimensionValue getDimensonValue(LedgerDimensionValueSet _defaultDimension) { DefaultDimensionView defaultDimensionView; ; select firstonly DisplayValue from defaultDimensionView where defaultDimensionView.Name == 'dimensionName' && defaultDimensionView.DefaultDimension == _defaultDimension; return defaultDimensionView.DisplayValue; }
Keep daxing!!
No comments:
Post a Comment