Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Fixed ledger dimension in D365

(0) ShareShare
ReportReport
Posted on by 480

I´m developing an integration solution in D365 but I have problem with the ledger dimensions. It works fine to create the records in LedgerJournalTrans and the field ledgerDimension gets a value but if there is a a fixed value set on one of the main account it is never set. I have tried to explain my code below. The dimension values are added to a container and past on to LedgerDimensionDefaultingEngine together with Main account and Dimension Hierarchy. Sometimes dimension2 is not set from the file, then it should be set from a Fixed value instead but that is not working.

    // runable Job

    public static createDimensionJob(Args _args)
    {  
    container con;
    str 10                  dimension1 = "first";
    str 10                  dimension2 = "second";
    str 10                  dimension3 = "third";
   
    DimensionDefault defaultDimension;
    recId mainAccountRecId;
    recId dimHierarchyId;
    LedgerDimensionAccount ledgerDimensionAccount;
    LedgerJournalAC ledgerAccount = "1234";

    con = conIns(con, 1, dimension1);
    con = conIns(con, 2, dimension2);
    con = conIns(con, 3, dimension3);
          
    mainAccountRecId = MainAccount::findByMainAccountId(ledgerAccount).RecId;
    defaultDimension = MyClass::createDefaultDimension(con);
    dimHierarchyId = MyClass::getDimensionHierarchyId(ledgerAccount, defaultDimension);
   
    ledgerJournalTrans.LedgerDimension = LedgerDimensionDefaultingEngine::getLedgerDimensionFromAccountAndDim(mainAccountRecId, dimHierarchyId, defaultDimension);
    }
 
    //MyClass

    public static recId createDefaultDimension(container _conDimAttrValues)
    {
        DimensionFinancialTag               dimFinancialTag;
        FinancialTagCategory                tagCategory;
        DimensionAttributeDirCategory       dimAttrDirCategory;
        DimensionAttribute                  dimAttr;
        DimensionAttributeValue             dimAttrValue;
        DimensionAttributeValueSetStorage   dimAttrValueSetStorage;
        int                                 i;
        str 10                              strDimAttrValue;

        // Create storage
        dimAttrValueSetStorage = new DimensionAttributeValueSetStorage();

        for (i = 1; i<=conLen(_conDimAttrValues); i++)
        {
            strDimAttrValue = conPeek(_conDimAttrValues,i);

            if (strDimAttrValue)
            {
                // Find FinancialTag
                select firstonly RecId
                    from dimFinancialTag
                    where dimFinancialTag.Value == strDimAttrValue
                    join RecId from tagCategory
                        where tagCategory.RecId == dimFinancialTag.FinancialTagCategory
                    join RecId from dimAttrDirCategory
                        where dimAttrDirCategory.DirCategory == tagCategory.RecId
                    join dimAttr
                        where dimAttr.RecId == dimAttrDirCategory.DimensionAttribute;

                // Add to storage
                if (dimFinancialTag.RecId)
                {
                    dimAttrValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAttr, strDimAttrValue);

                    if (dimAttrValue.RecId)
                    {
                        dimAttrValueSetStorage.addItem(dimAttrValue);
                    }
                }
            }
        }

   

*This post is locked for comments

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 Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans