I am currently working on a project, where I have to know, if the current installation is a multi tenant installation or not. There are different reasons why you might want to find this out, but in this case, I am actually generating code that then can be imported into the database – and obviously, I do not want to allow this for multi tenant installations.
I hope you find it useful, it works with all versions of NAV down to 2013 R2 (did not check on 2013 or 2009). There is a slight difference in each of the versions, I am going to note that below.
I created a function for this and it can easily be used anywhere in the system. First, we need to declare a .NET variable in this function and this is actually the one that needs to be changed based on what NAV version you are using. Here is the declaration
Subtype: Microsoft.Dynamics.Nav.Types.ServerUserSettings.’Microsoft.Dynamics.Nav.Types, Version=10.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35′
The “Version=” part needs to be replaced with the following:
- 2017: Version=10.0.0.0
- 2016: Version=18.104.22.168
- 2015: Version=22.214.171.124
- 2013 R2: Version=126.96.36.199
The actual code is only two lines:
IsMultitenant() : Boolean
ServerUserSettings := ServerUserSettings.Instance();
It first instantiates the .NET Variable, which is actually part of every NAV deployment – it is a DLL Microsoft ships with NAV. The next part just determines, if the “Multitenant” ServerUserSettings property equals true.
That’s it. Can’t get easier than that.