Показать сообщение отдельно
Старый 29.07.2020, 16:12   #1  
Blog bot is offline
Blog bot
Участник
 
23,359 / 790 (73) +++++++
Регистрация: 28.10.2006
a33ik: How to change the value of a default dimension of a record
Источник: http://daxonline.org/1699-how-to-cha...-a-record.html
==============

Replace default financial dimension value
Check that financial dimension value exists:
public static DimensionAttributeValue VKValidateFinancialDimensionValue(DimensionAttribute _dimensionAttribute, str _dimensionValue, boolean _noError = false){ DimensionAttributeValue dimensionAttributeValue; dimensionAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValueNoError(_dimensionAttribute, _dimensionValue, false, true); if (!dimensionAttributeValue && !_noError) { error(strFmt("@SYS342560", _dimensionValue)); } return dimensionAttributeValue;}Get financial dimension value:
public static DimensionValue VKGetFinancialDimensonValue(DimensionDefault _dimensionDefault, Name _dimensionName){ DefaultDimensionView defaultDimensionView; select firstonly DisplayValue from defaultDimensionView where defaultDimensionView.Name == _dimensionName && defaultDimensionView.DefaultDimension == _dimensionDefault; return defaultDimensionView.DisplayValue;}
Change/replace financial dimension value:
public static DimensionDefault changeFinancialDimensionValue(DimensionDefault _dimensionDefault, Name _dimensionName, DimensionValue _newDimensionValue){ DimensionAttributeValueSetStorage dimensionAttributeValueSetStorage; DimensionAttribute dimensionAttribute; DimensionValue oldDimensionValue; DimensionDefault newDimensionDefault; // Get current value oldDimensionValue = BHFFunctions::getFinancialDimensonValue(_dimensionDefault, _dimensionName); // Build DimensionAttributeValueSetStorage dimensionAttributeValueSetStorage = DimensionAttributeValueSetStorage::find(_dimensionDefault); // Remove old dimension value dimensionAttribute = DimensionAttribute::findByName(_dimensionName); dimensionAttributeValueSetStorage.removeDimensionAttributeValue( DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute, oldDimensionValue).RecId); // Set new dimension value if(_newDimensionValue) { dimensionAttributeValueSetStorage.addItem( DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute, _newDimensionValue, false, true)); } newDimensionDefault = dimensionAttributeValueSetStorage.save(); return newDimensionDefault;}
Other helper classes, which contain static methods to help with finantial dimensions:
DimensionDefaultingService
AxdDimensionUtil
DimensionDefaultingEngine



Источник: http://daxonline.org/1699-how-to-cha...-a-record.html