Read Server & Tenant Settings from C/AL Code

26 Oct

Back in April 2015 I wrote an article about reading server settings with C/AL code. Unfortunately, that code didn’t work in NAV 2015 and above. However, the question pops up now and then, and I decided to give it another try. Being curious myself, of course…

And I found a solution that works on NAV 2016. Didn’t test it with NAV 2015, but I’m sure one of you will. Smile

A Codeunit that demonstrates the solution is available on Github.

The solutions is using two dll’s from Dynamic NAV:

  • Microsoft.Dynamics.Nav.Types.dll
  • Microsoft.Dynamics.Nav.Ncl.dll

You only need to copy those dll’s from the NAV server folder to the add-in folder on the development server in order to compile the object. No need to do that on any production server, at runtime the dll’s will automatically be picked from the NAV server folder.

Here is a screenshot of the code. Didn’t pay a lot of attention to make it very fancy. It does the trick, and it’s up to you how to implement it. Don’t forget to add some error handling as well. Smile


The code works in both single en multi-tenant environments. In single tenant environments the database settings from the server settings and the tenant settings will just be the same.

Take a look in the server config file for the list of setting names that are available.


This example uses undocumented features of Dynamics NAV. It is not guaranteed that it will work in the future. Be very careful with using those dll’s, using them incorrectly can cause unexpected disconnects of clients. Use at your own risk, no warranties.

8 thoughts on “Read Server & Tenant Settings from C/AL Code

  1. Hi,
    Thanks for sharing this info – it’s very useful.
    I am using using your old solution with Microsoft.Dynamics.Nav.Types. ServerUserSettings.’Microsoft. Dynamics.Nav.Types on NAV 2016. It works OK for me with one exception – I cannot get correct ServerName (it returns Database Server instead of NAV server name).
    I think in your new approach ServerName is not available too. Do you have any solution for that?


    • Hi Viktoras,

      To get the NAV Server name is quite easy, you don’t need to use .Net at all.

      Declare a variable ServerInstanceRec of type Record, Subtype Server Instance (table 2000000112)

      in C/AL type:

      And now you can find information like:
      ServerInstanceRec.”Server Computer Name”
      ServerInstanceRec.”Server Instance Name”


  2. Pingback: Read Server & Tenant Settings from C/AL Code |

  3. Hi,

    This code indeed works great for NAV 2016. However, in NAV 2017 I can not use the Microsoft.Dynamics.Nav.Types library although I have put it in the add-ins folders and i closed the clients and reset the service tier. Did you check if this trick still works for NAV 2017?

    With kind regards,

    Erik Heirbaut

  4. Pingback: Read Server & Tenant Settings from C/AL Code - Kauffmann @ Dynamics NAV - Dynamics NAV Users - DUG

      • Oddly, the client displays the service and database name in the upper right hand corner, but there is no function in C/Side or NAV .Net to retrieve this data. I just continually find it frustrating that Microsoft has set us back to hunting and gathering for information.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.