How to Get Financial Dimension Values from Default Dimension in D365 F&O (X++)

 Introduction

Default Dimensions appear everywhere in D365 F&O - on Customers, Vendors, Inventory Items, Main Accounts, Projects, and more. When building customizations, integrations, or reports, you will frequently need to read a specific dimension value (like Cost Center or Department) stored in a Default Dimension field.

This post walks through a clean, reusable static X++ helper method to do exactly that.


Default Dimension vs Ledger Dimension — What's the Difference?

Before jumping into the code, it's important to understand this distinction because developers often confuse the two:

Default Dimension - This is a RecId pointing to a set of default dimension values attached to a master record - like a Customer account, Vendor, or Item.
It represents dimension defaults, not a posted account combination, you'll find it on tables like CustTable.DefaultDimension, VendTable.DefaultDimension, InventTable.DefaultDimension, etc.

Ledger Dimension - This is a RecId pointing to a fully resolved account + dimension combination used in actual transactions and journal lines, you'll find it on tables like LedgerJournalTrans.LedgerDimension, CustTrans.LedgerDimension, etc.

Both are dimension data, but they live in different framework tables and require different queries to read from.

Here is the complete static method:

public static str getDimensionValueFromDefaultDimension(LedgerDimensionValueSet _dimensionRecId, Name _dimName)
{
    DimensionAttributeValueSetItem dimAttrValueSetItem;
    DimensionAttributeValue        dimAttrValue;
    DimensionAttribute             dimAttr = DimensionAttribute::findByName(_dimName);
    str dimensionValue;
    select firstOnly DisplayValue from dimAttrValueSetItem
        where dimAttrValueSetItem.DimensionAttributeValueSet == _dimensionRecId
        exists join dimAttrValue
            where dimAttrValue.RecId == dimAttrValueSetItem.DimensionAttributeValue
            && dimAttrValue.DimensionAttribute == dimAttr.RecId;
    dimensionValue = dimAttrValueSetItem.DisplayValue;
    return dimensionValue;
}

How to Use It

Place this method in your utility or helper class (e.g., DimensionHelper). Then call it like this - 

// Reading default dimensions from a Customer record

CustTable custTable = CustTable::find("CUST-001");


str costCenter = DimensionHelper::getDimensionValueFromDefaultDimension(

    custTable.DefaultDimension, "CostCenter");


str department = DimensionHelper::getDimensionValueFromDefaultDimension(

    custTable.DefaultDimension, "Department");


info(strFmt("Cost Center: %1, Department: %2", costCenter, department));




Found this useful? Drop a comment below or share it with your D365 developer network. Stay tuned for more X++ tips! 🚀

Comments