Sunday, April 12, 2015

Hi All

Hope All Dynamics Ax consultants are doing good and rocking in implementations of powerful, simple and agile ERP MS Dynamics Ax 2012 :) .

This post by me subjects to populating data from some master in dimension values. You could also use the same logic in creating dimension values in migrations.

The code here was used in a job. Let's have a look

static void createBatchDim(Args _args)
         OMOperatingUnit     operatingUnit;
         DimensionAttributeValueSetStorage   dimstorage;
         InventBatch         inventBatchTable,inventBatchTableDim;
         Name dimName = "L4_CostCenter";
         str 255 dimValue;
         DimensionAttribute   dimattributeContract;
         DimensionAttributeValue       dimAttributeValue;
         recId                           defaultDim;
        while select inventBatchTable
            where inventBatchTable.inventBatchId!=""
            select  operatingUnit
                where operatingUnit.OMOperatingUnitNumber == inventBatchTable.inventBatchId &&
                      operatingUnit.OMOperatingUnitType   == OMOperatingUnitType::OMCostCenter;
                    operatingUnit.OMOperatingUnitNumber = inventBatchTable.inventBatchId;
                    operatingUnit.OMOperatingUnitType = OMOperatingUnitType::OMCostCenter;
                    operatingUnit.Name = inventBatchTable.inventBatchId;
                    dimStorage = DimensionAttributeValueSetStorage::find(InventTable::find(inventBatchTable.itemId).DefaultDimension);
                    dimattributeContract = DimensionAttribute::findByName(dimName);
                    dimValue = inventBatchTable.inventBatchId;
                         dimAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimattributeContract, dimValue, true, true);
                        defaultDim =;

Here I had to populate inventory batch as cost center dimension which is linked to General Ledger>Setup>Organization>Cost centers

So i just picked up the inventory batch which didn't exist in cost center master and made the available in dimension values of Cost center dimension.

Hope this post would surely help you. In case of any query you could simply comment over here.

Happy DAXing :) 

No comments:

Post a Comment