Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Suggested answer

Set a certain financial dimension

(2) ShareShare
ReportReport
Posted on by 1,297
Hi,

How to set a certain financial dimension by code?

So in SalesTable header, i have mutiple finanical dimensions, where one of them i want to fill it based on salesLine

So this "flow" is empty in SalesTable, and I want to fill it by code based on the "Flow" value for one of the SalesLines that have the highest salesPrice


how can i do that?

So i was able to get the "Flow" value for the SalesLine with the highest SalesPrice... it's the DisplayValue from from dimensionAttributeValueSetItemView
but now how to set it for SalesTable??
        SalesTable                          salesTable;
        SalesLine                           salesLine;
        DimensionAttribute                  dimensionAttribute;
        DimensionAttributeValueSetItemView  dimensionAttributeValueSetItemView;


        select firstonly RecId from dimensionAttribute where dimensionAttribute.Name == 'Flow';

        select firstonly DefaultDimension from salesLine 
         order by SalesPrice desc
         where salesline.SalesId == 'XXXSO' ;

        select firstonly DisplayValue from dimensionAttributeValueSetItemView
            where dimensionAttributeValueSetItemView.DimensionAttributeValueSet == salesLine.DefaultDimension
                && dimensionAttributeValueSetItemView.DimensionAttribute == dimensionAttribute.RecId;

        ttsbegin;
        //select forupdate salesTable where salesTable.SalesId == 'XXXSO';
        //salesTable.DefaultDimension = salesline.DefaultDimension
        ttscommit;
 
Categories:
  • Waed Ayyad Profile Picture
    Waed Ayyad 6,790 Super User 2024 Season 2 on at
    Set a certain financial dimension

    Hi, 

    Is your issue resolved? If yes, mark the answers that helped you as verified. 

    Thanks,

    Waed Ayyad

  • Waed Ayyad Profile Picture
    Waed Ayyad 6,790 Super User 2024 Season 2 on at
    Set a certain financial dimension

    Hi, 

    Is your issue resolved? If yes, mark the answers that helped you as verified

    Thanks,

    Waed Ayyad

  • Justin Kruger Profile Picture
    Justin Kruger 76 on at
    Set a certain financial dimension
    Hi,
     
    Once you have your dimension combination value that you get by calling DimenstionAttributeValueSetStorage.save() you can assign it to your DefaultDimension field.
     
    DimensionDefault defaultDimension;
    
    defaultDimension = dimensionAttributeValueSetStorage.save();
    
    ttsbegin;
    salesTable.DefaultDimension = defaultDimension;
    salesTable.update()
    ttscommit;
     
  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 230,573 Most Valuable Professional on at
    Set a certain financial dimension
    You said you debugged the code and didn't see the value, but not where do you expect to see the value.
     
    The purpose of this code is generate a new dimension combination value (RecId), which is returned by save() method. An obvious problem of your code is that you ignore this value; you haven't assigned it to to salesTable.DefaultDimension.
  • .. Profile Picture
    .. 1,297 on at
    Set a certain financial dimension
    Hi,

    I wrote this code but it's not working
    when i debugged dimensionAttributeValueSetStorage after calling addItem, i didn't see the new value, even though i can see the value in  dimensionAttributeValueSetItemView.DisplayValue​​​​​​​
            SalesTable                          salesTable;
            SalesLine                           salesLine;
            DimensionAttribute                  dimensionAttribute;
            DimensionAttributeValueSetItemView  dimensionAttributeValueSetItemView;
            DimensionAttributeValueSetStorage   dimensionAttributeValueSetStorage;
            DimensionAttributeValue             dimensionAttributeValue;
    
            select firstonly RecId from dimensionAttribute where dimensionAttribute.Name == 'Flow'
       
            select DefaultDimension, SalesId from salesLine where salesLine.SalesId == XXXSO;
    
    
            if(salesLine.DefaultDimension)
            {
                select firstonly DisplayValue from dimensionAttributeValueSetItemView
                where dimensionAttributeValueSetItemView.DimensionAttributeValueSet == salesLine.DefaultDimension
                    && dimensionAttributeValueSetItemView.DimensionAttribute == dimensionAttribute.RecId;
                
                salesTable = salesTable::find(salesLine.SalesId);
    
                dimensionAttributeValueSetStorage = DimensionAttributeValueSetStorage::find(salesTable.DefaultDimension);
    
                dimensionAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute, dimensionAttributeValueSetItemView.DisplayValue, true, true);
                dimensionAttributeValueSetStorage.addItem(dimensionAttributeValue);
    
                dimensionAttributeValueSetStorage.save();
            }


     
  • Suggested answer
    Waed Ayyad Profile Picture
    Waed Ayyad 6,790 Super User 2024 Season 2 on at
    Set a certain financial dimension
    Hi,
     
     

    Thanks,

    Waed Ayyad

    If this helped, please mark it as "Verified" for others facing the same issue

     
     
     
     

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey Pt 2

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,573 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans