Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to create a new department financial dimension value?

(1) ShareShare
ReportReport
Posted on by

Hello, I am a beginner in Dynamics AX 2012 development, currently doing internship. So the task I am doing here is simply for learning purposes. I have come across a brick wall. I have this task to import some purchase order lines from excel file using x++. Now while I have done most of it, I can't seem to get how to create a financial dimension in Departments. I need a new financial department dimension because the one I am importing does not exist as a default value.

This is the dimension I want a new value created in.

http://imgur.com/sI4TSuh

Now I have googled and read that this is a system defined financial dimension and you can't really create a new value there. Now what boggles me is this:

http://imgur.com/toO1isA

This is my colleague's Department values (he is also an intern btw).

Apparently, he has more values than me, and he has the one I need - 51PARDAV. I have asked him how he created those values, but the thing is he didn't create them. Those values were created by previous interns and it just happens to be that his AX 2012 client was used by one of these past interns. My client is new and so I have to solve this issue myself.

I guess i should also mention that I have no idea why "Use values from:" is in Lithuanian language on my colleagues client while in options language is set to EN-US.

This is the method I am using to insert a financial dimension: [Source: http://daxldsoft.blogspot.lt/2012/11/ax-2012-financial-dimension-update.html]

purchTable = purchTable::find('PURCHID', true);  
  purchTable.DefaultDimension = getNewDefaultDimension(purchTable.DefaultDimension, "COSTCENTER", "YOURVALUE");  
  purchTable.update();

The difference is that I am inserting a default dimension into purchline:

purchLine.DefaultDimension = this.getNewDefaultDimension(purchLine.DefaultDimension, "Department", "51PARDAV");

And this is the code of getNewDefaultDimension method:

static RecId getNewDefaultDimension(RecId defaultDimension, Name dimName, str 255 dimValue)  
 {  
   DimensionAttributeValueSetStorage  dimStorage;  
   Counter               i;  
   DimensionAttribute         dimAttributeCostCenter;  
   DimensionAttributeValue       dimAttributeValue;  
   dimStorage = DimensionAttributeValueSetStorage::find(defaultDimension);  
   dimAttributeCostCenter = DimensionAttribute::findByName(dimName);  
   if(dimValue)  
   {  
     dimAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAttributeCostCenter, dimValue, true, true);  
     dimStorage.addItem(dimAttributeValue);  
   }  
   else  
     dimStorage.removeDimensionAttribute(DimensionAttribute::findByName(dimName).RecId);  
   return dimStorage.save();  
 }  


Does anyone how to solve my issue? Or maybe someone can steer me in the right direction of how to approach the problem?

*This post is locked for comments

  • Verified answer
    RE: How to create a new department financial dimension value?

    Thanks for your reply, your solution did the trick that I was looking for.

    After a bit of goofing around, I also found that this path also does the job:

    Company / General Ledger / Setup / Organization / Departments

  • Verified answer
    Abhishek_mishra Profile Picture
    Abhishek_mishra 405 on at
    RE: How to create a new department financial dimension value?

    I am not able to open the link provided by you.

    however you can create new department values from below path in AX.

    Company/Human resources/Common/Organization/Departments/Departments

    Hope this resolves your issue.

  • RE: How to create a new department financial dimension value?

    I feel that your outburst is unjustified. Did you read my post and understood the problem / help that I am asking with?

    My problem is that I want to create a department financial dimension and if you bothered to look at the images I made, you can see that the button "New" is greyed out - meaning I can't create a dimension value in Department.

    Now the method that I posted it doesn't create the dimension, it only looks for it if it is existing, which is not, and returns me error that Dimension Attribute Value 51PARDAV does not exist.

    So what I'm looking for is either a way to create the financial dimension through x++ code, or an alternative to the pictures I posted.

  • RE: How to create a new department financial dimension value?

    Hi!

    You can set breakpoint and debug code and see WTF

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,409 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans