Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Add values in a ledger dimension segmented Entry in X++

Posted on by Microsoft Employee

hi

I have a segmented entry field for ledger dimensions. In this field one of the segments is projectId. I want to retrieve all the other dimensions in to their places based on the entered projectId.

The ProjectId is number 3 in the row.

8228.Screenshot_5F00_15.png

*This post is locked for comments

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Add values in a ledger dimension segmented Entry in X++

    here is how I solved the problem.

    public boolean leave()
    {
        str 100 projIdLocal;
        boolean ret;
        DimensionAttributeValueCombination  ledgerdim;
        DimensionStorage                    dimStorage;
        DimensionAttributeValueCombination  dimAttrValueComb;
        ProjTable                           projTableLocal;
        DimensionDefault                    dimensionDefault;
    
    
    
        ret = super();
    
        if(ledgerJournalTable.JournalName == "HEN")
        {
            dimStorage = DimensionStorage::findById(LedgerJournalTrans.LedgerDimension);
    
            projIdLocal = element.getProjIdDimension(LedgerJournalTrans.LedgerDimension);
    
            projTableLocal  = ProjTable::find(projIdLocal);
    
            if(projTableLocal.Name)
            {
                LedgerJournalTrans.Txt = "Hensat - " +  projTableLocal.Name;
            }
    
            dimensionDefault = projTableLocal.DefaultDimension;
            if (dimensionDefault)
            {
                LedgerJournalTrans.LedgerDimension = DimensionDefaultingService::serviceCreateLedgerDimension(LedgerJournalTrans.LedgerDimension, dimensionDefault);
                LedgerJournalTrans.OffsetLedgerDimension = DimensionDefaultingService::serviceCreateLedgerDimension(LedgerJournalTrans.OffsetLedgerDimension, dimensionDefault);
            }
         }
    
    
    
        return ret;
    }


  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Add values in a ledger dimension segmented Entry in X++

    Update:

    I have had a little progress in the process. Now I can get the entered ProjectID from the Segmented Entry. But My question is how I can select the default Dimensions of the project and insert them in the Segmented entry. Here is my code that I have placed in the Leave() of the AccountNum control on the LedgerJournalTransDaily form. 

    I can select the default dimensions for a project. But I dont know how to insert the values in the segmented entry field. 

    public boolean leave()
    {
        str 100 projIdLocal;
        boolean ret;
        DimensionAttributeValueCombination  ledgerdim;
        DimensionStorage                    dimStorage;
        DimensionAttributeValueCombination  dimAttrValueComb;
        ProjTable                           projTableLocal;
    
    
    
    
        ret = super();
    
    
    
    
        if(ledgerJournalTable.JournalName == "HEN")
        {
            dimStorage = DimensionStorage::findById(LedgerJournalTrans.LedgerDimension);
    
            projIdLocal = element.getProjIdDimension(LedgerJournalTrans.LedgerDimension);
    
    
            select projTableLocal
                where projTableLocal.ProjId == projIdLocal;
    
            LedgerJournalTrans.Txt = "Hensat - " + projTableLocal.Name;
    
            while select * from projTable
               where ProjTable.ProjId == projIdLocal    //  Det skal være det indtastede projektId
             join RecId from dimensionattributeValueset
                   where  dimensionattributeValueset.RecId == projTable.DefaultDimension
             join RecId, DisplayValue from dimensionAttributeValueSetItem
                   where dimensionAttributeValueSetItem.DimensionAttributeValueSet == dimensionattributeValueset.RecId
             join RecId from dimensionAttributeValue
                   where dimensionAttributeValue.RecId == dimensionAttributeValueSetItem.DimensionAttributeValue
             join RecId, Name from dimensionAttribute
                   where dimensionAttribute.RecId == dimensionAttributeValue.DimensionAttribute
             {
                 info(dimensionAttribute.Name+"----"+ dimensionAttributeValueSetItem.DisplayValue);
                    //I guess it will be here that I must merge in to the Segmented Entry. 
             }
         }
    
    
    
        return ret;
    }


  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Add values in a ledger dimension segmented Entry in X++

    Just to make sure that I have described my question well :)

    In the below image I have entered a projectId in this segmented entry field. What I want is, when I leave the field, the rest of the default dimensions which are "Department" and so on, gets populated. I really dont know how to solve this :)

    3122.Screenshot_5F00_16.png

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Add values in a ledger dimension segmented Entry in X++

    It could be the solution I want, but I cant see anywhere that he retrieves the default dimensions based on the ProjId. Its a little hard to see what he is doing.

  • Dick Wenning Profile Picture
    Dick Wenning 8,705 on at
    RE: Add values in a ledger dimension segmented Entry in X++

    ok something like this

    dynamicsaxspace.com/.../set-financial-dimension-values-through-code-in-ax-2012

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Add values in a ledger dimension segmented Entry in X++

    Hi Dick

    thanks for your reply,

    I want to insert values in the segments that are already in the fields, based on the projectId we enter :)

  • Dick Wenning Profile Picture
    Dick Wenning 8,705 on at
    RE: Add values in a ledger dimension segmented Entry in X++

    dynamicsaxinsight.wordpress.com/.../ax-2012-add-financial-dimension-for-your-table

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