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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Set a certain financial dimension

(2) ShareShare
ReportReport
Posted on by 1,979
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:
I have the same question (0)
  • Suggested answer
    Waed Ayyad Profile Picture
    9,042 Super User 2025 Season 2 on at
    Hi,
     
     

    Thanks,

    Waed Ayyad

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

     
     
     
     
  • .. Profile Picture
    1,979 on at
    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
    Martin Dráb Profile Picture
    238,050 Most Valuable Professional on at
    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.
  • Justin Kruger Profile Picture
    186 on at
    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;
     
  • Waed Ayyad Profile Picture
    9,042 Super User 2025 Season 2 on at

    Hi, 

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

    Thanks,

    Waed Ayyad

  • Waed Ayyad Profile Picture
    9,042 Super User 2025 Season 2 on at

    Hi, 

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

    Thanks,

    Waed Ayyad

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

News and Announcements

Season of Giving Solutions is Here!

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 678 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 407 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 283 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans