Microsoft Dynamics AX development

Scenario: I have to update the value “Fixed / Not fixed” for the financial dimensions in the main accounts with the DIXF.

Aufnahme2

First of all I’ve added a new field in the DMFMainAccountEntity in order to save the string with the “Fixed (= 1) / Not fixed (= 0)” values:

DMFMainAccountEntity.FixedDefaultDimensionStr

The format is the same as the value for the field DefaultDimensionStr. In the file I have for example: 1-0-0-0-0-0 (the first financial dimension has a fixed value and the other not).

I’ve added a new method in the class DMFDimensionHelper:

public static RecId generateFixedDefaultDimension(str _dimValueFixedString, DMFDataSourceProperties _sourceProperties, str _keyValue)
{
container                           dimAttributeList, dimValueFixedList;
int                                 j;
DimensionAttributeSetStorage        storage;
RecId                               defDimRecId;
DimensionFixed                      dimFixed;
DimensionAttribute                  dimAttr;

if (_sourceProperties && _dimValueFixedString)
{
//save the financial dimension from the string
dimAttributeList  = str2con(_sourceProperties.DimensionAttribute, enum2str(_sourceProperties.ChartOfAccountsDelimiter), false);
//save the values (fixed/not fixed) from the string
dimValueFixedList = str2con(_dimValueFixedString, enum2str(_sourceProperties.ChartOfAccountsDelimiter), false);

storage = new DimensionAttributeSetStorage(enumNum(DimensionFixed));

for (j=1;j<=conLen(dimAttributeList);j++)
{
if(conPeek(dimAttributeList,j))
{
//convert the string into enumeration
dimFixed = DMFEntityBase::string2Enum(conPeek(dimValueFixedList,j), enumNum(DimensionFixed));
//search the dimensionAttribute
dimAttr  = DimensionAttribute::findByName(conPeek(dimAttributeList,j));
//add the dimension attribute with the new value
storage.addItem(dimAttr.RecId, dimAttr.HashKey, dimFixed);
}
}
//save the new object
defDimRecId = storage.save();
}

return defDimRecId;
}

In the DMFMainAccountEntityClass, in the method generateMainAccountLegalEntity I’ve added the following code:

accountLegalEntity.FixedDimensions  = DMFDimensionHelper::generateFixedDefaultDimension(entity.FixedDefaultDimensionStrWPC,
dsProperties,
entity.MainAccountId);

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

Tag Cloud

%d bloggers like this: