Microsoft Dynamics NAV 2013 Tip 2

After long time I have found some free time and subject worth to write something. During my work on my DynamicsNAVProtocolHandler (with some help from Daniel Steiner from redIT) I have found one thing I didn’t know about in NAV 2013.

Do you need to know server, instance or some setting of the NAV Server you are connected to?

If you need something regarding the NST you are just using in the NAV Win client, you can be inspired by code from codeunit 9500. There is one DotNet class you can use for this:

Microsoft.Dynamics.Nav.Types.ConfigSettings

If you use this class, you gain access to the server settings. And if you are lucky, you can even change the settings (property CanSetSettings will tell you that). This class have method to read any setting by entering the name of the setting, or there are specific properties for the most used.

Bug in CU 9500

You can hit this bug when you are running NST on non-default port and you want to open session list. Because the session list is opened by CU 9500 by generating hyperlink and launching it, you can correct this bug easilly. The code is just not taking into account the server port. We are lucky, that this part is in C/AL and not hardcoded into the client. Just extend the code like this:

   1:  

   2: ServerComputerName := Config.GetStringSetting('Server');

   3: ServerInstance := Config.GetStringSetting('ServerInstance');

   4: ServerPort := FORMAT(Config.ClientServicesPort); //added line

   5:  

   6: //Add parameter %4 into the URL

   7: UrlString := STRSUBSTNO('DynamicsNAV://%1:%4/%2/%3/debug',ServerComputerName,ServerInstance,COMPANYNAME,ServerPort);

   8: HYPERLINK(UrlString);


 


You can see both ways of reading the settings:


  • through the GetStringSetting
  • through property (CientServicesPort)

Conclusion


Thanks for the DotNet interop and the standard NAV assemblies which allows NAV developer to have access to NAV inside values! I hope that I will find more connections between .NET and C/AL like access to the actions etc. from within C/AL code.


 


Have a nice days with playing with C/AL!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>