#NAVdevTips 11: Default Dimensions – small change but important

Have you ever built new master table similar to Customer or Vendor? Maybe not every day but probably you did. So you know that Default Dimensions are something which is a must in such case.

How you handle Default Dimensions in NAV 2017?

Not so easy on first look. Let’s prepare some example first. I created new table Person and page Person Card for which we need to add dimensions.

But what happed if I wanted to open Dimensions? I got the error that table ID must not be 50001 in Default Dimension Table.

To add Default Dimensions we need to do one additional thing. New event subscriber must be created which will have only one line adding our table to list of allowed tables.

How you handle Default Dimensions in NAV 2018 and Business Central?

Let’s check what is happening behind the scene. In Codeunit 408 in NAV 2017 there was function with listed all tables to which default dimension were allowed. And at the end of it you could see our event OnAfterSetupObjectNoList.

In NAV 2018 and Business Central we would not see this anymore. Instead of it we will get new function DefaultDimObjectNoList. It has got two other functions. First one DefaultDimObjectNoWithoutGlobalDimsList contain similar list to this which you can see in 2017 version. But as on below screen it has only few lines. Also as you can notice there is no integration event which we used.

So how system knows that you can add Default Dimension to other tables?

There is a second function which finds all tables which have field with name Global Dimension. It is called DefaultDimObjectNoWithGlobalDimsList.

From this function you can notice few things

1st

You do not need anymore to use event OnAfterSetupObjectNoList to allow users add default dimension – simply add fields Global Dimension 1 and Global Dimension 2. Of course in such case you need to handle Global Dimension choose and you will anyway need to handle one additional event to change global dimensions on your card when changing default dimension. For this you can use OnAfterUpdateGlobalDimCode event present in table Default Dimension (352).

2nd

Still there is a integration even OnAfterSetupObjectNoList means if you do not like the idea with Global Dimensions fields you can use the same pattern as in NAV 2017 – however I would recommend you to use Global Dimensions as in most cases you should use the same logic as in standard NAV or Business Central.

3rd

When creating any table which does not need Default Dimensions either add field Dimension Set ID field to a table (for example document header or line) or not use Global Dimension name of field (for example in any of setup tables)

4rd

This function skips two tables – first one General Ledger Setup makes sense from beginning. It is setup table which set the Dimension Shortcuts. Second is Job Task and this is because of exception. This table for dimensions use Job Task Dimension table.

 

11 Comments

Add a Comment

Your email address will not be published.