CostCenter lookup in Dynamics 365 for finance and operations



If you've spent any time customizing Dynamics 365 Finance & Operations, you already know that dealing with financial dimensions can quickly get tedious. Writing custom lookup logic usually involves joining DimensionAttribute and DimensionAttributeValue tables, binding query ranges, and setting up a full SysTableLookup from scratch.

Most of the time, you don't actually need to reinvent the wheel. Microsoft has a neat little utility class hiding in the standard framework that handles dimension lookups in a single line of code.


The Problem

Let's say you added a custom field on a form (or a report dialog), and you need users to pick a CostCenter value. You want a standard lookup window to open with all active Cost Center dimension values, but without writing 30 lines of boilerplate X++ code.


The One-Line Solution

Override the lookup() method on your form control or dialog field, and use the LedgerMatrixReportHelper_CN helper class:

/// <summary>
/// Lookup method on form control
/// </summary>
public void lookup()
{
    // Opens a built-in dimension lookup for CostCenter
    LedgerMatrixReportHelper_CN::dimensionValueLookup(this, "CostCenter");
}

Quick Breakdown

  • this – Refers to the current control. The class uses this reference to display the lookup right below the field and push the chosen value back automatically.
  • "CostCenter" – The exact string name of your financial dimension as defined in General Ledger > Chart of Accounts > Dimensions > Financial Dimensions.

A Few Things to Keep in Mind

  • It works for any dimension: Need a lookup for Department, BusinessUnit, or a custom dimension? Just swap out "CostCenter" with your dimension's exact name string.
  • No query maintenance: Because it relies on standard platform methods, you don't have to worry about manually filtering inactive dimension values or handling table relations.
  • Where to use it: This trick works great on standalone form controls, dialog fields (SysOperation/RunBase), and extension classes where you just need a clean value picker.

Give it a try next time you need a quick dimension lookup—it saves plenty of time and keeps your extension code clean!

Comments