web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Financial Dimension troubles

(0) ShareShare
ReportReport
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

I have the same question (0)
  • Suggested answer
    Ludwig Reinhard Profile Picture
    Microsoft Employee on at

    Hi,

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

    Best regards

    Ludwig

  • Yakhin Rifat Profile Picture
    75 on at
    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.
  • André Arnaud de Calavon Profile Picture
    300,970 Super User 2025 Season 2 on at

    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
    75 on at

    Hi André.

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

  • Suggested answer
    André Arnaud de Calavon Profile Picture
    300,970 Super User 2025 Season 2 on at

    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;
    }
  • guk1964 Profile Picture
    10,888 on at

    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.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Ali Zaidi Profile Picture

Ali Zaidi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans