Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Answered

How to create a new department financial dimension value?

Posted on by Microsoft Employee

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?

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    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.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    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.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to create a new department financial dimension value?

    Hi!

    You can set breakpoint and debug code and see WTF

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,513 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,862 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans