Thursday, 21 December 2017

AX7 Dimensions

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();
===================================================================

1 comment:

  1. Do you need Finance? Are you looking for Finance? Are you looking for finance to enlarge your business? We help individuals and companies to obtain finance for business expanding and to setup a new business ranging any amount. Get finance at affordable interest rate of 3%, Do you need this finance for business and to clear your bills? Then send us an email now for more information contact us now via (financialserviceoffer876@gmail.com) whats-App +918929509036 Dr James Eric Finance Pvt Ltd Thanks

    ReplyDelete