Codeunit to Update Global Dimensions in G/AL Entry Table

Hi all,

I am new in NAVISION and I have problems to update Global Dimensions fields in table G/L Entry.

Please can you advice me how to do this?

Best,

Maddy

What version of Nav you are using? The way to update ledger entry dimension has changed from previous version to current version, hence it will be helpful if you can let me know which version are we dealing here.

What version of Nav you are using? The way to update ledger entry dimension has changed from previous version to current version, hence it will be helpful if you can let me know which version are we dealing here.

I am using NAV 2017

Ok, are you planning to update the Global dimension fields via a spreadsheet in other words you have a spreadsheet with G/L entry entry no. and dimension value or you want to hardcode the dimensions for all the transactions.

I need to hardcode it. So what I need is that for all entries that do not have Global Dimension 1 Code or Global Dimension 2 Code filled i need to fill them using table Dimension Set Entry by Dimension Set Id.

Ok, the simple way to do this would be in the G/L entry table create the below function. You will need developer license.

ValidateShortcutDimCode(FieldNumber : Integer;VAR ShortcutDimCode : Code[20])
DimMgt.ValidateShortcutDimValues(FieldNumber,ShortcutDimCode,“Dimension Set ID”);

Declare a local variable Dimmgt codeunit Dimensionmanagement.

Now create a new processing only report with G/L entry as dataitem and run through the G/L entry table.

If “global dimension 1 code” = ‘’ then begin

validateshortcutdimcode(1,‘110’); //1 is the global dimension 1 code and 110 is the global dimension 1 value

“global dimension 1 code” := '110;

modify;

end;

If “global dimension 2 code” = ‘’ then begin

validateshortcutdimcode(2,‘210’); //2 is the global dimension 1 code and 210 is the global dimension 2 value

“global dimension 2 code” := '210;

modify;

end;

This will update your g/L entry table and also will create the new dimension set. DO NOT TOUCH THE DIMENSION SET ENTRY TABLE, ONCE THE DIMENSION SET ENTRY BREAKS YOU WILL HAVE TO REBUILD IT WITH THE DIMENSION SET TREE WHICH IS A PAIN.

Are you a developer, If not then you need to chase for one, If yes then I will suggest check table Sales Header, you will find a field there Shortcut Dimension 1, check the OnValidate Trigger, you will find a piece of code, understand the concept and then the same you need to map for GL Entry.

Hi Maddy,
I would strongly recommend against doing this!!!

Even IF you had a developer license, and could follow the guide lines from our friendly co-members, then do not do this.

The general rule in NAV and any other ERP system, that posted entries are not modified after they are posted.

Changing dimensions is also part of that, but more gray zone. But I guess you are just trying to clean up older entries, which were made without dimension 1+2? And that you’ve already update the setup, so that this doesn’t happen in the future.

If that is the case, then always remember that your G/L Entries are connected to sub ledger entries. I.e. if you have a sales invoice, then besides G/L entries it also creates customer ledger entries, item ledger entries and vat ledger entries. So if you update the G/L Entry, then should should ALSO update dimension 1+2 + dimension set id on the connected ledger entry.

If you don’t, then you may end up with inconsistent data when comparing reports/statistics. Something you may not find out right now, but will haunt you (your employer or customer) in the years to come and cost sweat and tears and money to debug, because nobody remember you changed all the dimension in 2-3 years from now.

This is generally not something you should even touch, if you are not already an experienced developer!

100% agree on what Erik said. Undoubtedly it’s never recommended to change after Posting and eventually if doing for G/L Entry then it may turn out to be a nightmare sooner than later some day. I still remember this post of mine (https://dynamicsuser.net/nav/f/technical/91359/global-dimension-change/483639) and how intense I have to struggle to solve it out and apparently this was a standard process still it sucked me out, so all thumbs up to what Eric said.

Customer Ledger Entry, Vendor Ledger Entry, Vat Entry, Bank Account Ledger Entry - These are some critical tables which are all dependent on G/L Entry. So now it could be envisioned how deadly this would be. if you are not highly experienced developer don’t do, if you still doing keep these tables and broad vision in your mind.

Hi Erik ,

Please If I want to fill the field global dimension for a posted entries manuelly it’s possible ?

Thanks a lot ,

Hello Taha

I am not Erik though, but the answer will be the same from Erik. By design (and Law) it is not possible to changed it on posted entries manually. What you have to do is to reverse your postings without the dimension value, and then “redo” the postings with the dimension.

However, a developer with the right skills and knowledge of how Postings generally works in NAV/BC will be able to develop some code that can do a quick and dirty fix for it. BUT it is not as easy as it might seem if the G/L entries also have Cusstomer/Vendor/Detailed intries or Item Ledger/Value Entries. And I myself whom has been a developer and Accountant for more than 35 years… would not do stuff like this (as Erik also says).

Many thanks for your reply Palle ,

Many years ago I was working on a large project where we had this requirement. Due to periodically changes in the way the company had to report their financial data to their head quarter, then they had to be able to add, remove, merge or change dimension values of already posted entries.

And of course we had to still do it legally, which meant fully auditable tracking all changes. We had worked on it for more than 9 months, when I left the project in 2003 to start a new job. And it was still not fully production ready.

So I can’t really say if they ever got it working, only that unless you have deep pockets and no other way to do it, then don’t do even consider it. If there are entries which have been posted wrong, then reverse them and recreate them with new dimensions instead.

Btw. the company did have deep pockets and an owner in Seattle who had reporting requirements, different from the way it was previously done in Navision A/S. So it had to be done.

Thanks a lot Erik