Create a page Activate debugging Debug Other useful information when debugging
For this example we will be using Microsoft Dynamics NAV 2009 R2 and Microsoft Visual Studio 2010 Professional.
Create a page
To use as an example for debugging, let's create an empty page (for example 50000 RTCDebugTest) with a new action called “Messages”. In code of this action, we create two local variables:
And write the following code lines in “Messages - OnAction()”:
n := 21; MESSAGE('%1', n);
str := 'Hello World!'; MESSAGE('%1', str);
Just to access the actions a little faster, we will change these properties of the action:
Promoted=Yes; PromotedIsBig=Yes; Image=Start;
Save and compile.
For this we need to go to CustomSettings.config of the Service folder (“%PROGRAMFILES(X86)%\Microsoft Dynamics NAV\60\Service\CustomSettings.config” on x64, or “%PROGRAMFILES%\Microsoft Dynamics NAV\60\Service\CustomSettings.config” on x86) and set this to “true”:
<add key="EnableDebugging" value="true" />
Once we restart the NAV service (by default “MicrosoftDynamicsNavServer”) and run the RTC, we will see that in “%PROGRAMDATA%\Microsoft\Microsoft Dynamics NAV\60\Server\MicrosoftDynamicsNavServer\source” it has created a single .cs file for each object that we have on the RTC:
Remember to change the value of “EnableDebugging” back to false, and to restart the NAV service, whenever we are done debugging, since if we forget it will continue to generate the .cs files in the background and the RTC will take longer to load.
Now we open Visual Studio (right click and “Run as Administrator”). Now we need to open the source code of our page, so we go to “File -> Open -> File” (Ctrl + O) and from all the generated .cs files we open the page that we have just created (50000 RTCDebugTest):
Now we can see our C/AL (commented) and its equivalent in C# for each line:
In this case we have set a breakpoint for the C# line that equals our C/AL “n := 21;”, by doing double click on the left margin or by going to “Debug -> Toggle Breakpoint”. The next step will be to go to “Tools -> Attach to Process” (Ctrl + Alt + P). From the list of processes we select our NAV service and click on “Attach” (if you can’t see the NAV service in the list, check that it is running, and mark “Show processes from all users”:
Now if we run the page on the RTC, and click on the “Messages” action:
We will see that Visual Studio will stop right on our breakpoint:
And we can continue to debug using F10 (Step Over) and F11 (Step Into):
This is all that you need to know in order to start debugging your RTC code. The following information contains important details and also extra information in case you need to debug a little deeper.
Other useful information when debugging
If we make a change in our page in NAV
In this case, after saving and compiling our page in the Classic Client and running the page again, Visual Studio will show us this message box indicating that the source code has changed and we if would like to Update it:
After accepting it, we will see the page code now reflects the changes we did to the page.
We can analyze the behavior of our variables during execution, either by setting the mouse over the variable that we are interested in:
Or by pinning it if we want to monitor its value through execution:
Or we can also add the variables that we would like to monitor to a “Watch” (double click over the variable, and drag it to the “Watch”:
We can also monitor our local variables in the “Locals” tab. In this example, we can see how our “str” or type Text in C/AL creates an object of type “NavText” in C#. For these cases in which our variables are objects, we can also see the values of any attributes of the class, like for example “MaxLength”, which we had left by default in 30.
In the breakpoints panel we can see all the breakpoints that we have defined (for this and other .cs):
Sometimes we might want to stop at a breakpoint only if a certain condition is true. For this we can create a conditional breakpoint by right clicking on the breakpoint and selecting “Condition…”, and we will see a window where we can set the condition:
In this case we set it to stop only when “n” is different than “2” (which obviously always happens, so it will always stop, but this is just a silly example). The conditions we set will all appear in the breakpoints panel marked with a white cross and with the condition.
In the Call Stack panel (Debug -> Windows -> Call Stack) we can see the calls that happened up to the breakpoint or line in which we have stopped. For example, if we modify the code of the page so that in “OnAction” we call a function “Funcion1” and from this one we call another function called “Funcion2”, and set a breakpoint on “Function2” we will get the following call stack:
Registers, Memory and Dissasembler
If for whatever reason we need to analyze at a lower level what is happening underneath, we can also check the state of the registers (Debug -> Windows -> Registers), where we will see in red any values which have changed in the last executed line:
Or check the value that was loaded in a certain memory address (Debug -> Windows -> Memory). You can also see the disassembly code (Debug -> Windows -> Disassembly) and debug from here instruction by instruction:
Juliet R. Moreiro Bockhop
Microsoft Dynamics NAV Support Engineer
“Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability or fitness for a particular purpose. This mail message assumes that you are familiar with the programming language that is being demonstrated and the tools that are used to create and debug procedures.”
Welcome to Convergence Day Two, and “Hello” to Microsoft Dynamics NAV 2013!
As announced in yesterday’s opening keynote, and in the official Convergence press release, NAV “7” is now officially called Microsoft Dynamics NAV 2013. With a planned Q4 calendar year 2012 general availability date, and an expected May 2012 Beta release, NAV 2013 will be the first Dynamics ERP solution to be cloud-enabled for Windows Azure!
Yesterday’s announcements also outlined the crucial role that Microsoft’s ISV ecosystem will play in offering services hosted on Windows Azure to provide customers with the specialized vertical capabilities required for their businesses. Read more in the full press release and in the supporting blog on the Edge.
The NAV General Session rode on a wave of excitement generated at the keynote (OK, pardon the pun, but surf boards in downtown Houston…?). The room was packed as NAV General Manager Dan Brown presented key meta- trends affecting and transforming the SMB business landscape; the NAV product strategy and future roadmap, a cool Sitka customer video (hence the surf boards); and a host of “gnarly” NAV 2013 demos – including the first broad public demo of the NAV Web Client.
Didn’t catch the General session, or the Keynote? Not even at Convergence? No problem – look for them on demand on the Convergence Website.
So how do you follow that? Well, today is another great chance to immerse yourself in the product. Get vocal in an Interactive Discussion, get to the bottom of things in a Deep Dive Session, or stay current in a Concurrent Session. Then share your thoughts on Twitter: #MSDNNAV #CONV12. My tip for the day: 3 great sessions about how to start your journey toward the coming release, and what you can look forward to when you get there:
Surf’s Up for NAV!
There have been some changes from the tax authorities since this post. For information about the changes, see Changes in Dutch Tax BAPI Support - Part 2.
Electronic communication with the Dutch Tax administration is based on trusted connections using Digital Certificates. In 2011 an incident has occurred with Diginotar, one on the Certificate Authorities (CA), resulting in a situation that an infiltrator was able to create new certificates on his own for every random domain. This made the whole certificate-based environment unsecure and required facilities to make sure that trusted digital communication remains possible in the future.
The Dutch Tax administration evaluated the different existing communication channels and decided to phase out one of these channels: BAPI-PIN. It has also been decided to no longer use Diginotar certificates but to give KPN (Getronics) the role as the Certificate Service Provider (CSP) for the future.
SUBMITTING VAT AND ICP DECLARATIONS USING MICROSOFT DYNAMICS NAV
You can choose to submit VAT and or ICP to the Dutch Tax Authority by manually filling in a web form (www.belastingdienst.nl). There is a limit however for the ICP declaration. The website allows a maximum of 99 lines to be entered manually. An ICP Declaration report can be printed from Microsoft Dynamics NAV to use as a guideline.
Microsoft Dynamics NAV supports the BAPI channel electronic communication. Within the BAPI channel both PIN and PKI method are possible by Microsoft Dynamics NAV.
PIN is the public key method and mostly used within the Microsoft Dynamics NAV community. For this method you only need the certificates from the Tax authorities and CSP. To get these you have to fill in the fields on tab Certificates of the ‘Elec. Tax Declaration Setup’ page and get the certificates by the function ‘Get CA Tax Auth. Certificates’. The certificates for the PIN method can be acquired at no cost.
PKI is the private key method. This method uses user certificates for encrypting the message and providing a digital signature. For PKI 4 different types of certificates are needed:
A company has to buy the user certificates. On the KPN site you will find all this information.
With respect to PIN and PKI the following timeline has been set by the Tax authorities (latest communication in Feb 2012):
MICROSOFT DYNAMICS NAV AND BAPI PIN
In order to continue using PIN until 2013 you will need to change the certificate settings to KPN before June 2012.
To realize this, please change the following settings in the “Electr. Tax Declaration Setup” under the “Certificates” Fast TAB (production environment parameters). Make sure you have no ongoing declarations.
CN=KPN Corporate Market Tax CA G2,O=KPN Corporate Market BV,C=NL
CN=Belastingdienst,OU=Servercertificaat E - zie CPS,L=Apeldoorn Joost van den Vondellaan 14 (0000),O=Belastingdienst (2000000002),C=NL
No need to change other settings. After that you can renew the certificate by using the function “Get CA Tax Auth. Certificates” and do your normal submissions again.
For testing purposes you can use the following test environment parameters (you should have a test account at Tax Authorities):
CN=KPN Corporate Market Tax TEST CA G2,O=KPN Corporate Market BV,C=NL
CN=TEST Belastingdienst,OU=Servercertificaat E - zie CPS,L=Apeldoorn Joost van den Vondellaan 14 (0000),O=Belastingdienst (2000000002),C=NL
MICROSOFT DYNAMICS NAV AND BAPI PKI
If you are using the PKI method to submit the declarations, then you will need to ask for a (re)new(al) certificate at KPN. The Tax Authorities have already informed the users of PKI certificates on this process. Microsoft needs to investigate if Microsoft Dynamics NAV is able to work with KPN certificates under which conditions.
Tests for requesting KPN PKI certificates and submitting declarations are in process at the moment. You will be informed in a timely manner what changes are needed.
Here is a roundup of Microsoft Dynamics NAV resources from around the web.
Help & Support
So now we’re just hours away from the big Convergence 2012 Keynotes and General Sessions that kick off tomorrow morning at 9:00. The NAV team is already geared up and ready to welcome you with some really awesome content and plenty of opportunities to discover the full potential of your Microsoft Dynamics NAV solution.
But don’t wait until tomorrow to get engaged. Convergence has a lot to offer if you want to get a head start on the conference experience today. You might already have decided to donate your time and energy to one of the charitable volunteer opportunities. If not, then you can register at the conference center from 11:30 this morning and then swing by the EXPO Experience area and have a look around. You won’t be disappointed. There are hundreds of featured exhibitors, an impressive NAV booth, and lots to experience.
Later, from 1:30 this afternoon, you can take in some great content delivered by our friends from the NAVUG. Catch the NAVUG General session, and then take part in an NAV-focused break-out session or two.
Whatever else you are planning, don’t forget to come and join us at the Convergence reception from 6-10:00 at Minute Maid Park. It’s easy to get there by shuttle, it’s free, and it’s going to be a lot of fun. But don’t stay too late! The opening keynote with Kirill Tatarinov and Kevin Turner kicks things off at 9:00 sharp tomorrow – with the NAV General Session and breakouts to follow from 11:00.
Over the next three days we hope you’ll discover more about Microsoft Dynamics NAV 2009, and get some valuable insight into what’s coming in Microsoft Dynamics NAV “7”. We’re ready with lots of sessions, interactive discussions, tips and tricks, user groups and hands-on labs. And in the true spirit of Convergence, there will be many opportunities to meet other members of the NAV community and share experience and insights.
There’s plenty to see and do! See y’all out there.
The NAV Team
Great to see so many of you at the reception last night!
Hope you’re all fired up and ready to go today as Convergence 2012 kicks into high-gear. First stop: look for some exciting NAV-related announcements and a very cool NAV customer story in the keynote at 9:00.
Afterwards, you’ll want to run over and grab a good seat for the NAV General Session with Dan Brown at 11:00. Here, you’ll learn how smart businesses thrive on change – with Microsoft Dynamics NAV. How NAV users can benefit from the investments we’ve made in a vivid and connected user experience, and from the new opportunities to interact with their data. Plus, you’ll hear how NAV “7” adds enhanced core functionality and embraces the cloud – so our customers canaccess their solutions from anywhere and boost their business productivity.
After the general session, it’s time to get face-to-face and hands-on in the Experience Center. Here you can get answers to your burning NAV questions – free of charge :-) - from Microsoft support engineers. You can see live product demos and feedyour inner geek on the EXPO floor. And then get your hands dirty, and immerse yourself in NAV features and functionality in a hands-on environment.
There will still be plenty of time to take in a couple of the many NAV concurrent sessions. Tip of the day – try Microsoft Dynamics NAV at Convergence 2012: THE OVERVIEW. The clock is ticking and time is short, so this session is a great place to start planning the key NAV sessions you don’t want to miss over the next three days.
We’re on our way. Have a fantastic day, and remember to share your thoughts, and hear the buzz, on Twitter: @MSFTDynamicsERP #MSDNNAV #CONV12.
So, somehow, this is already the last day of Convergence 2012. This week has been fantastic. We have seen a huge amount of excitement around NAV, great attendance and participation in the NAV sessions, and impressive engagement and enthusiasm at the Experience Center.
But don’t pack your bags just yet. This may be the last day of Convergence 2012, but there is still a whole lot going on, starting with Colin Powell as the closing keynote speaker at 9:00.
You could use the rest of the day to catch up on the NAV sessions or interactive discussions you may have missed. You could stop by the Experience Center one last time, or visit like-minded peers in a Birds-of-a-Feather session.
Today would also be a great day to “Ask the Experts” and learn more about Microsoft Dynamics NAV & Microsoft SharePoint, or pick up those last Tips & Tricks around leveraging the RoleTailored User Experience or around Supply Planning.
This has been a super Convergence for NAV. And, if the level of enthusiasm and spirit we have seen among the community is any indication, the future looks awesome for NAV, our customers and partners. So we hope you will look back on this week as a great investment in your time and energy – and look forward to exciting times ahead, with the promise of continued innovation and value from your current solution, and in anticipation of Microsoft Dynamics NAV 2013 on the horizon.
On behalf of the entire Microsoft Dynamics NAV team, I want to thank you for your continued support and passion for Microsoft Dynamics NAV – and for making Convergence 2012 an amazing experience for us all.
But, it’s not over ‘til it’s over. We’re here until 5:30! Make the most of it.
And remember to share your final thoughts on Twitter:@MSFTDynamicsERP #MSDYNNAV #CONV12.
-The NAV Team