Dynamics 365 Business Central: How to add Dimensions to the page (Other than Global and Shortcut dimensions)

Dynamics 365 Business Central

Hi, Readers.
Today I would like to discuss how to add dimensions other than Global and Shortcut dimensions to the page.

Dimensions are values that categorize entries so you can track and analyze them on documents, such as sales orders. Dimensions can, for example, indicate the project or department an entry came from.
When dimensions and values are set up, you can define global and shortcut dimensions on the General Ledger Setup page that will always be available to select as fields on journal and document lines, and ledger entries, without having to open the Dimensions page first.

  • Global Dimensions are used as filters, for example, on reports, batch jobs, and XMLports. You can use only two global dimensions, so choose dimensions you will use often.
  • Shortcut Dimensions are available as fields on journals, document lines, and ledger entries. You can create up to eight of these.

For Global Dimensions, you can easily use Personalize to add them to any page you want.

For Shortcut Dimensions, you can add shortcut dimensions to any entries page from BC17.3, such as general ledger entries, customer or vendor ledger entries, and many others.
For more details: Use shortcut dimensions in G/L entries for financial reporting

In the previous version of BC, you can refer to the following post to add Shortcut Dimensions to the page.
How to add Shortcut Dimensions on the page in Dynamics 365 Business Central (Shortcut Dimension 2 ~ 8)

But as you might know, in Business Central there are no limitations in the number of Dimensions you can setup (I personally do not recommend anyone to have more than the standard 8 dimensions). If you set dimensions other than Shortcut dimensions, or if you set more than 8 dimensions, how do you add them to the page?

In this post, I will briefly explain how to add these Dimensions. Hope it will help.

For example:
I have set 8 dimensions in General Ledger Setup.

Then I added two more dimensions, Season and Project.

Create a sales order, add these dimensions and post it. Finally, I can find the dimensions in G/L Entry.

So if I want to display these two dimensions on the General Ledger Entries page, how to find their relationship.

In Business Central, a dimension set is a unique combination of dimension values. It is stored as dimension set entries in the database. Each dimension set entry represents a single dimension value. The dimension set is identified by a common dimension set ID that is assigned to each dimension set entry that belongs to the dimension set.

G/L Entry (17): Dimension Set ID

Dimension sets are stored in the Dimension Set Entry table as dimension set entries with the same dimension set ID.

Dimension Set Entry (480): Dimension Set ID and Dimension Code

A easy way is to add a new FlowField to display Dimension Value.
For example:

TableExtensions:

Source Code:

tableextension 50100 ZYGLEntryExt extends "G/L Entry"
{
    fields
    {
        field(50100; ZYSeason; Code[20])
        {
            Caption = 'Season';
            FieldClass = FlowField;
            Editable = false;
            CalcFormula = lookup("Dimension Set Entry"."Dimension Value Code" where("Dimension Set ID" = field("Dimension Set ID"), "Dimension Code" = const('SEASON')));
        }
        field(50101; ZYProject; Code[20])
        {
            Caption = 'Project';
            FieldClass = FlowField;
            Editable = false;
            CalcFormula = lookup("Dimension Set Entry"."Dimension Value Code" where("Dimension Set ID" = field("Dimension Set ID"), "Dimension Code" = const('PROJECT')));
        }
    }
}

PageExtension:

Source Code:

pageextension 50100 ZYGeneralLedgerEntriesExt extends "General Ledger Entries"
{
    layout
    {
        addafter("External Document No.")
        {
            field(ZYSeason; Rec.ZYSeason)
            {
                ApplicationArea = All;
            }
            field(ZYProject; Rec.ZYProject)
            {
                ApplicationArea = All;
            }
        }
    }
}

General Ledger Entries:

You can also Only use variables to display dimension value on General Ledger Entries page.
For example:

Source Code:

pageextension 50100 ZYGeneralLedgerEntriesExt extends "General Ledger Entries"
{
    layout
    {
        addafter("External Document No.")
        {
            field(ZYSeason; ZYSeason)
            {
                Caption = 'Season';
                ApplicationArea = All;
            }
            field(ZYProject; ZYProject)
            {
                Caption = 'Project';
                ApplicationArea = All;
            }
        }
    }

    trigger OnAfterGetRecord()
    var
        DimensionSetEntry: Record "Dimension Set Entry";
    begin
        if DimensionSetEntry.Get(Rec."Dimension Set ID", 'Season') then
            ZYSeason := DimensionSetEntry."Dimension Value Code";
        if DimensionSetEntry.Get(Rec."Dimension Set ID", 'Project') then
            ZYProject := DimensionSetEntry."Dimension Value Code";
    end;

    var
        ZYSeason: Code[20];
        ZYProject: Code[20];
}

You can use the above method to add dimensions to any page. And in the program, I now use hardcoding to force which dimension to be displayed. You can also create setting fields to manage the dimensions you wish to display.

Find out more about Dimension Set Entries Overview from Microsoft Docs.

END

Hope this will help.

Thanks for your reading.

ZHU

コメント

Copied title and URL