Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Financial Dimension troubles

Posted on by 75

Hi all!

I added a new segment to existing account structure. Now I'm trying to set new segment value into the existing GeneralJournalAccountEntry table records using code, but it fails with error: 

"Function DimensionStorage.getSegment has been incorrectly called.".I looked through DimensionStorage and ran into some code in DimensionStorage::findById(), here is it:

packedDimensionStorage = DimensionCache::getValue(DimensionCacheScope::DimensionStorageInstance, [_dimensionCombinationId, _validateStructureChanges]);

packedDimensionStorage - container that contains the parameters of DimensionStorage, including quantity of segments. This quantity of segment is wrong - new segment is not considered.

I've tried to call DimensionCache::clearAllScopes(), but the problem still there. How can I solve my problem?

*This post is locked for comments

  • guk1964 Profile Picture
    guk1964 10,877 on at
    RE: Financial Dimension troubles

    If its only for a report then I would prefer to make the change outside the system e.g.in Excel, or at least in a  non production Ax environment and run the report from there.

  • Suggested answer
    André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,269 Super User 2024 Season 2 on at
    RE: Financial Dimension troubles

    Hi Yakhin,

    The following coding was used by me in the past for adding/changing a dimension value to an existing set. This was used for the default dimensions on e.g. customers or vendors. I have not used it for the ledger dimension set (including the main account segment).

    It reads the existing set. Then creates a new one with all values from the initial set. The last part is adding/changing a certain value. It might help you in your scenario.

    server private static DimensionDefault setDimensionValue(DimensionDefault _defaultDimension, Name _attributeName, DimensionValue _dimensionValue)
    {
        Map                                 setMap;
        DimensionAttributeValue             dimAttrValue;
        DimensionAttributeValueSetStorage   valueSetStorage;
    
        MapEnumerator                       mapEnumerator;
    
        DimensionDefault                    defaultDimension;
    
        if (! _dimensionValue)
        {
            return _defaultDimension;
        }
    
        setMap = DimensionDefaultingEngine::getDefaultDimensionSpecifiers(_defaultDimension);
        valueSetStorage = new DimensionAttributeValueSetStorage();
    
        mapEnumerator = setMap.getEnumerator();
        while (mapEnumerator.moveNext())
        {
            dimAttrValue = DimensionAttributeValue::findByDimensionAttributeAndValue(DimensionAttribute::find(mapEnumerator.currentKey()), mapEnumerator.currentValue(), false, true);
            valueSetStorage.addItem(dimAttrValue);
        }
    
        dimAttrValue = DimensionAttributeValue::findByDimensionAttributeAndValue(DimensionAttribute::findByName(_attributeName), _dimensionValue, false, true);
        valueSetStorage.addItem(dimAttrValue);
        defaultDimension = valueSetStorage.save();
    
        return defaultDimension;
    }
  • Yakhin Rifat Profile Picture
    Yakhin Rifat 75 on at
    RE: Financial Dimension troubles

    Hi André.

    Yes, I have auditor's approval. Presently, the system is being integrated. I need to change posted transaction for report generating

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,269 Super User 2024 Season 2 on at
    RE: Financial Dimension troubles

    Hi Rifat,

    The GeneralJournalAccountEntry table is a table which hold posted ledger entries. Do you have an approval from an external auditor to change posted transactions? Why do you need to change posted transactions?

  • Yakhin Rifat Profile Picture
    Yakhin Rifat 75 on at
    RE: Financial Dimension troubles
    private RefRecId setLedgerDimVal(RefRecId _ledgerDimension, DimensionValue _val)
    {
        RefRecId                ret;
        DimensionStorageSegment dimensionStorageSegment;
        DimensionStorage        dimensionStorage    = DimensionStorage::findById(_ledgerDimension);
        MainAccount             mainacc             = MainAccount::findByLedgerDimension(_ledgerDimension);
        RefRecId                dimHierId           = DimensionHierarchy::getAccountStructure(mainacc.RecId);
        DimensionHierarchyLevel dimHierLevel        = DimensionHierarchyLevel::findByDimensionHierarchyAndDimAttribute(
                                                                    dimHierId,
                                                                    finDimParm.R_IncExpDimensionAttribute);
        DimensionAttributeValue dimAttraValue;
    
        dimAttraValue = DimensionAttributeValue::findByDimensionAttributeAndValue(
                            DimensionAttribute::find(finDimParm.R_IncExpDimensionAttribute),
                            _val,
                            false,
                            true);
    
        dimensionStorageSegment = DimensionStorageSegment::construct(
            dimAttraValue.getValue(),
            dimAttraValue.RecId,
            dimAttraValue.HashKey);
    
        dimensionStorage.setSegment(dimHierLevel.Level, dimensionStorageSegment);
    
        ret = dimensionStorage.save();
    
        return ret;
    }
    "finDimParm" variable is my customized table. I looked through debuger - all values are initialized.
  • Suggested answer
    Ludwig Reinhard Profile Picture
    Ludwig Reinhard Microsoft Employee on at
    RE: Financial Dimension troubles

    Hi,

    Are you operating an older AX2012 system? If so, please check LCS for available hotfixes.

    Best regards

    Ludwig

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans