Defaulting Ledger Dimensions [AX 2012]

In my earlier post, I had described a way to default financial dimensions through code. In this post, I will describe about the way we can default Ledger Dimensions (DimensionAttributeValueCombination) through code.

We have seen how we can fetch the values from a dimension combination in my post here. But what if we have to default them using code.

Say you are creating a general journal and want to default the Account and Offset account fields. These fields have been changed to segmented controls and now store RecIds for DimensionAttributeValueCombination table.

The job below will help you in doing that.

Below are the screen shots of dimensions for the two record ids used below:



static void setLedgerDimensions(Args _args)


    LedgerDimensionAccount  ledgerDimension; // Record id for LedgerDimension(DimensionAttributeValueCombination) containing combination of dimensions

    LedgerDimensionAccount  mainAccDimension; // Record id for LedgerDimension(DimensionAttributeValueCombination) containing default account for main account RecId


    RefRecId    emplDimAttrRecId = 5637147951; // For ex. purpose defaulting it to required DimensionAttributeValueSet RecordId

    RefRecId    dimensionRecId = 5637145941; // For ex. purpose defaulting it to required DimensionAttributeValueSet RecordId



     * For information on finding the record ids for required dimension combinations

     * Go through the following blog




    // Get the default account for main account 110154

    mainAccDimension = DimensionStorage::getDefaultAccountForMainAccountNum("110154");


    //Find or create the LedgerDimension record for required combination

    //Param1 – Ledger Dimension record id, in our case Default account for main account

    //Param2 – Default Dimension Record Id for 1st Dimension Combination

    //Param3 – Default Dimension Record Id for 2nd Dimension Combination

    //Param4 – Default Dimension Record Id for 3rd Dimension Combination

    ledgerDimension = DimensionDefaultingService::serviceCreateLedgerDimension(





    info(strFmt("%1: %2", ledgerDimension, DimensionAttributeValueCombination::find(ledgerDimension).DisplayValue));


This is the output



Friends I am updating the post to illustrate how we can default dimensions in case the account is  not a ledger account.

In the job above, you can use  the method getDynamicAccount instead of getDefaultAccountForMainAccount and get non-ledger account ledger dimensions. Here is a small job that shows the same.

static void getNonLedgerAccounts(Args _args)


    LedgerDimensionAccount  ledgerDim;

    ledgerDim = DimensionStorage::getDynamicAccount(‘VEN-00273’, LedgerJournalACType::Vend);

    info(strFmt("%1 -%2", ledgerDim, DimensionAttributeValueCombination::find(ledgerDim).DisplayValue));



16 thoughts on “Defaulting Ledger Dimensions [AX 2012]

  1. Hi Sumit,

    I have exactly the same requirement, but I have more dimensions. I am still confused how did you get this result which you showed in the infolog. Whereas I am getting a 0 ledgerDimension. Can you please elaborate further or can you add me on skype and then we can talk regarding this.

    Thanks in anticipation. My skype id is hussain.bandukda

    1. You can use method getDynamicAccount instead of getDefaultAccountForMainAccount to get the LedgerDimension for non-ledger accounts. Please see this job

      static void getNonLedgerAccounts(Args _args)
      LedgerDimensionAccount ledgerDim;
      ledgerDim = DimensionStorage::getDynamicAccount(‘VEN-00273’, LedgerJournalACType::Vend);
      info(strFmt(“%1 -%2”, ledgerDim, DimensionAttributeValueCombination::find(ledgerDim).DisplayValue));

  2. Hi Sumit,

    I finally got the right result. It was my understanding issue. Actually I was using the wrong mainAccDimension value. Now its working fine after providing the right dimension.

    Thanks for this usefull post.🙂

  3. HI Sumit,

    Is there a way to override or replace the existing dimension with the deafult one defined on the ‘Charts of accounts’?

    Consider an example where I have 3 dimension OU_1, OU3566,Conference/Seminar as per ur example.

    Now I have one default dimension ‘ABC_1’ set for the main account 110154 in ‘Charts of Account’. Let say instead of OU_1 I need to use the default dimension ABC_1.
    How would I do that? Any idea?

    1. If you just want to change the default dimensions, you can use following method “serviceReplaceAttributeValue” from DimensionDefaultingService. But if you wish to change the value of ledger dimensions, i am still working on it.

  4. Hi Sumit,

    Thanks for your response. Can you show me the usage of serviceReplaceAttributeValue method via example. I am not able to understand the logic of this method and there is no such help on google.

  5. Hi Sumit,

    I have a requirement in which I need to create LedgerJournalTrans entry from code. Now my Account Type is ‘Vendor’, my question is how will I generate a LedgerDimension for this vendor. As in Account Type ‘Ledger’ case I simply had the value in MainAccount table, but in this case I am not able to figure out th right method to create or replace dimension. As for Ledger case you used DimensionDefaultingService::serviceCreateLedgerDimension which is not working for this case.

    Any idea will be highly appreciated.


  6. Hello Sumit ,
    Thanks for the helpful post. I have a requirement where i have to apply filter on financial dimensions like purpose ,costcenter and department in report. how can i achive this .Data will fetched from LedgerJournalTrans Table for Customer based on finacial dimension .

    1. Functional requirment is user able to check the opening balance and collection amount received from customer, bank-in amount collection and closing balance amount after the deduction of bank-in collection.

  7. Hi sumit,

    I have to create a ledger dimension account (with a given default dimension)for a vendor type of account. I tried various methods but i couldnot. Is it possible to create a ledger dimension account for vendor type of account ? How can i do this ?

    can you please help me in this ?

    1. Hi Gangadhar,

      Are you looking at creating a Ledger dimension something similar to Main accounts? I have not tried it yet but I dont see a possibility. The values for Ledger dimensions are stored in DimensionAttributeValueCombination table and one field there is Main account. I will let you know if it is possible.

Leave a Reply

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

You are commenting using your 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 )

Google+ photo

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

Connecting to %s