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=188.8.131.52
- 2015: Version=184.108.40.206
- 2013 R2: Version=220.127.116.11
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.