create ledgerdimension from mainaccount in ax2012
in AX 2012 only whereas d365fo ,we have ledgerdimensionfacade is there
//SIG_22435_BudgetsInAXByCostCentre - 19- Sep -2023 - Hreddy
public LedgerDimensionDefaultAccount getDefaultAccountFromMainAccountRecId(MainAccountRecId _mainAccountRecId)
{
recId dimAttributeId;
DimensionAttributeValue dimAttributeValue;
int segmentIndex;
str newValue;
/*DimensionAttributeValue mainAcctDimAttrValue;
DimensionStorage dimStorage;
MainAccount mainAccount;
container result;
DimAttributeMainAccount attrMainAcc;
// Empty account is a zero ledger dimension
if (!_mainAccountRecId)
{
return 0;
}
result = DimensionCache::getValue(DimensionCacheScope::DimensionStorageInstance, [funcName(), _mainAccountRecId]);
if (result == conNull())
{
dimStorage = DimensionStorage::construct(1, LedgerDimensionType::DefaultAccount);
dimStorage.addAccountStructure(DimensionHierarchy::getHierarchyIdByHierarchyType(DimensionHierarchyType::DefaultAccount));
mainAccount = MainAccount::find(_mainAccountRecId);
select attrMainAcc where attrMainAcc.Value == mainAccount.MainAccountId;
mainAcctDimAttrValue = DimensionAttributeValue::findByDimensionAttributeAndEntityInst(DimensionAttribute::getMainAccountDimensionAttribute(),attrMainAcc.key, false, true);
dimStorage.setSegment(1, DimensionStorageSegment::constructFromValue(mainAccount.MainAccountId, mainAcctDimAttrValue));
result = [dimStorage.saveAsDefaultAccount()];
DimensionCache::insertValue(DimensionCacheScope::DimensionStorageInstance, [funcName(), _mainAccountRecId], result);
}
return conPeek(result, 1);*/
//mainAccount = MainAccount::find(_mainAccountRecId);
BudgetLineGrid_BudgetSegmentedEntry.loadSegments();
dimAttributeId = DimensionAttribute::getMainAccountDimensionAttribute();
newValue = MainAccount::find(_mainAccountRecId).MainAccountId;
if (strlen(newValue) > 0)
{
// First assume string is a record value
dimAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValueNoError(
DimensionAttribute::find(dimAttributeId),
newValue,
false,
true);
}
budgetLedgerDimensionController.sigSegmentValueChanged(1, dimAttributeValue, newValue);
BudgetLineGrid_BudgetSegmentedEntry.modified();
return 0;
}
Comments
Post a Comment