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.
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:
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