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 :
Microsoft Dynamics AX (Archived)

Compare the values of financial dimensions

(0) ShareShare
ReportReport
Posted on by

Hello ,i added a edit method of Cost Center on SalesTable on the header,and i want that when the financial dimension on lines is added ,to be compare with the value of financial dimension on header? What can i do for that..and in wich method? Thank you.

*This post is locked for comments

I have the same question (0)
  • Anton Venter Profile Picture
    20,376 Super User 2025 Season 2 on at

    There is no method for that, assuming that you want to compare all segments of the dimension, you can simply compare the DefaultDimension field values of the SalesTable and the (Sales) line. If my assumption is wrong, please explain more.

    if (SalesTable.DefaultDimension == SalesLine.DefaultDimension)
    {
        //add code here
    }


  • Community Member Profile Picture
    on at

    I dont want to compare all the segments..only Cost Center that i added on header,i want to compare with the Cost Center on lines,end when the values are different,it shows an error .Thank you

  • kvnkk Profile Picture
    800 on at

    Have a look in to this link community.dynamics.com/.../get-default-financial-dimension-values-through-x-code  it may gives idea.

  • Suggested answer
    Heinz Schweda Profile Picture
    1,367 on at

    Hello,

    you can query the view DefaultDimensionView like in the following example:

    static void validateDimensions(Args _args)
    {
        SalesLine salesLine = salesLine::findInventTransId("00010000");
        Salestable salesTable = salesLine.salesTable();
        DimensionValue dimensionValueLine;
        DimensionValue dimensionValueTable;
        #define.CostCenterName("CostCenter");
        
        dimensionValueLine = 
        (select firstOnly DisplayValue from DefaultDimensionView
        where DefaultDimensionView.Name == #CostCenterName
        && DefaultDimensionView.DefaultDimension == salesLine.DefaultDimension).DisplayValue;
        
        dimensionValueTable = 
        (select firstOnly DisplayValue from DefaultDimensionView
        where DefaultDimensionView.Name == #CostCenterName
        && DefaultDimensionView.DefaultDimension == salesTable.DefaultDimension).DisplayValue;    
        
        if (dimensionValueLine != dimensionValueTable)
        {
            warning("Do not match");    
        }
    }

    Regards,

    Heinz

  • Suggested answer
    Hossein.K Profile Picture
    6,648 on at
    Hi,
    Try this code:

    public static Boolean CompareDim(DimensionDefault _DimFrom, DimensionDefault _DimTO) { DimensionAttributeValueSetStorage storage_1,Storage_2; int attributeCount, attributeIndex; str attributeValue,AttributeVAlue1; boolean ret = true; // Get storage storage_1 = DimensionAttributeValueSetStorage::find(_DimFrom); Storage_2 = DimensionAttributeValueSetStorage::find(_DimTO); // Add attribute count attributeCount = storage_1.elements(); for (attributeIndex = 1; attributeIndex <= attributeCount; attributeIndex++){ // Add attribute value attributeValue = DimensionAttributeValue::find(storage_1.getValueByIndex(attributeIndex)).getValue(); attributeValue1 = DimensionAttributeValue::find(Storage_2.getValueByDimensionAttribute(storage_1.getAttributeByIndex(attributeIndex))).getValue(); //COmpare Values if( attributeValue != attributeValue1) return False; } return ret; }

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#2
TAHER Mehdi Profile Picture

TAHER Mehdi 3

#3
Nakul Profile Picture

Nakul 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans