My current requirement is, we are importing transactions from file. In which MainAccount, Dept and other dime values are existing. By using these values I need to create LedgerDimension and DefaultDimension.
I tried to use “TMSInvoiceApproval.findOrCreateDynamicDimension(DimensionDynamicAccount _account, DimensionDynamicAccount _dimensions)” method. But couldn’t able to pass parameter values in required format.
LedgerDefaultDimensionValueSet generateDefaultDimension(str _costCentre){
List dimensionValue = new List(Types::Class);
DimensionNameValueListContract dimensionNameValueListContract = new DimensionNameValueListContract();
DimensionStorageResult dimensionStorageResult;
DimensionAttributeValueContract dimensionAttributeValueContract;
//#costcentre is the macro for the name of CostCentre dimension attribute
dimensionAttributeValueContract = DimensionAttributeValueContract::construct(#costcentre, _costCentre);
dimensionValue.addEnd(dimensionAttributeValueContract);
dimensionNameValueListContract.parmValues(dimensionValue);
dimensionStorageResult = DimensionNameValueListServiceProvider::newForDimensionNameValueListContract(dimensionNameValueListContract).resolve();
return dimensionStorageResult.parmSavedRecId();
}
inventJournalTrans.DefaultDimension = generateDefaultDimension(“8099”);
=================================================================
In Ax 2012 we have class AxdDimensionUtil that is obsolete in Ax 7. The same should be happen with LedgerAccountDimensionResolver class in AX 7.
DimensionAttributeValueSetStorage dimensionAttributeValueSetStorage;
DimensionAttribute dimensionAttribute;
DimensionAttributeValue dimensionAttributeValue;
DimensionDefault dimensionDefault;
LedgerDimensionAccount ledgerDimensionAccount;
DefaultDimensionIntegrationValues dimensionNames;
DimensionDisplayValue dimensionValues;
DimensionDynamicAccount dynamicDimension;
dimensionAttributeValueSetStorage = new DimensionAttributeValueSetStorage();
dimensionNames = DimensionAttribute::find(DimensionAttribute::getWellKnownDimensionAttribute(DimensionAttributeType::MainAccount)).Name;
dimensionValues = '110110';
dimensionNames += SystemParameters::getChartOfAccountsDelimiter();
dimensionValues += SystemParameters::getChartOfAccountsDelimiter();
dimensionNames += "BusinessUnit";
dimensionValues += strReplace('001', SystemParameters::getChartOfAccountsDelimiter(), '\\' + SystemParameters::getChartOfAccountsDelimiter());
dimensionNames += SystemParameters::getChartOfAccountsDelimiter();
dimensionValues += SystemParameters::getChartOfAccountsDelimiter();
dimensionNames += "Department";
dimensionValues += strReplace('022', SystemParameters::getChartOfAccountsDelimiter(), '\\' + SystemParameters::getChartOfAccountsDelimiter());
LedgerAccountDimensionResolver ledgerAccountDimensionResolver = LedgerAccountDimensionResolver::newResolver(dimensionValues);
ledgerAccountDimensionResolver.parmDimensionFormat(dimensionNames);
dynamicDimension = ledgerAccountDimensionResolver.resolve();
===================================================================