Create record in DimensionAttributeValueCombination table manually.

Sometime we need this RecId value in DimansionAttributeValueCombination Table for some reasons likes putting new dimension in LedgerDimension field in LedgerJournalTrans Table, or somewhere else.

Suppose my Account structure likes: MainAcct - Dept - Woker - SubAcct - Item, you can custom base on your struture.

This code is for creating a record into DimansionAttributeValueCombination in code and then get RecID of this.

static void createDimensionAttributeValueCombination(Args _args)
    DimensionAttributeValueContract     ValueContract;
    DimensionAttributeValueCombination  davc;
    MainAccount                         valueMainAccount;
    DimensionStorage                    dimStorage;

    DimensionServiceProvider DimensionServiceProvider   = new DimensionServiceProvider();
    LedgerAccountContract LedgerAccountContract         = new LedgerAccountContract();
    List ListValueContract                              = new List(Types::Class);
    // Get main account with structure : Mainacct - DE - woker - subacct - item
    valueMainAccount = MainAccount::findByMainAccountId('910001'); //Get main account

    ValueContract = new DimensionAttributeValueContract();
    ValueContract.parmName('Department') ;
    ValueContract.parmValue('6020'); //Value for dimension Department

    ValueContract = new DimensionAttributeValueContract();
    ValueContract.parmName('Worker') ;
    ValueContract.parmValue('000001'); //Value for dimension ExpenseCode

    ValueContract = new DimensionAttributeValueContract();
    ValueContract.parmName('SubAcct') ;
    ValueContract.parmValue('교보생명'); //Value for dimension Project

    ValueContract = new DimensionAttributeValueContract();
    ValueContract.parmName('Item') ;
    ValueContract.parmValue('110329'); //Value for dimension Project


    //if combination is not exist then create new one
    dimStorage = DimensionServiceProvider::buildDimensionStorageForLedgerAccount(LedgerAccountContract);
    davc = DimensionAttributeValueCombination::find(;
    info(strFmt("RecId : %1 - DisplayValue : %2", davc.RecId, davc.DisplayValue));

or you can use this way

static void createDimension(Args _args)
    Struct      struct = new Struct();
    container   financialDimension;
    LedgerDimensionAccount legder;

    //// Get main account with structure : Mainacct - DE - woker - subacct - item
    struct.add('Department', '6020');
    struct.add('Item', '220006');
    struct.add('SubAcct', '교보생명');
    struct.add('Worker', '000002');

    financialDimension += struct.fields();
    financialDimension += struct.fieldName(1);
    financialDimension += struct.valueIndex(1);
    financialDimension += struct.fieldName(2);
    financialDimension += struct.valueIndex(2);
    financialDimension += struct.fieldName(3);
    financialDimension += struct.valueIndex(3);
    financialDimension += struct.fieldName(4);
    financialDimension += struct.valueIndex(4);

    legder = DimensionDefaultingService::serviceCreateLedgerDimension(


Max Nguyen

Max Nguyen
D365/AX, Azure Solution Architech - currently living and working in Seoul :)

Exception Handling in Dynamics 365 For Finance and Operation

When we write a code, or make a customization to Dynamics 365 For Operation which is using X++ should make use of Exception Handling to p...… Continue reading

Basic C# OOP Concept

Published on April 10, 2017