C/AL Editor in Dynamics NAV 2016
The 2016 version of Microsoft Dynamics NAV comes with a new C/AL editor. This is a big step forward for people that are writing code within Microsoft Dynamics NAV.
The C/AL editor have, in my mind, always been much behind other code editors in terms of usability, but with the 2016 version Dynamics NAV catches up a bit. This blog post is about the new features you will find when you start writing code in Dynamics NAV 2016.
The first thing that you will notice when you open the C/AL editor is how the functions looks with their colors etc. and that there are line numbers to the far left.
The functions can be expanded and collapsed manually by using the small +/- sign next to their names or through the Edit menu where you also can Collapse or Expand All at the same time. Kind of nice actually, no need go to the C/AL Globals anymore to see a list of the functions (just collapse them all and you see both the function names and their variables).
The line numbers will help with keeping track of where you are and navigating in the code. You can select entire lines by selecting the numbers on the left and when you are selecting lines in the code the editor does no longer select full rows when you select multiple rows. This means that you can do a selection that starts and ends in the middle of a row. Basic it seems like, but a nice addition (I always thought that the way the old editor worked when it came to selecting code was a bit annoying).
Then when you start wring your code the fun starts. You will see lines modified as highlighted in yellow.
Then when you compile your changes they show up as highlighted in green (even if the line does not compile actually 🙂 ).
Unfortunately after closing and reopening the object the yellow/green highlight is gone. Would have been cool if they remained as an indication of a part of the object that was custom modified (maybe a blue color or something).
As long as you don’t close the object you can also undo (ctrl+z) and redo (ctrl+y) your changes. Nice! 🙂 This is another one that seem like a basic thing, but you have never been able to do this before, which has been frustrating if you for example happen to delete a line by mistake and you have not saved your changes for a while (which have happen to me many times). The undo also works after the changes have saved, so you can save a change then test it and if it does not work you can undo it again, pretty cool (as long as you don’t close the object that is, if you close the object you are done with undoing).
Then when you start typing your code you see that it come with intellisense that provides easy access to variables, fields, functions etc., nice! This is probably the biggest change of them all.
The good old F5 (C/AL Symbol Menu) is still around but it does not seem like you can use it for inserting code anymore, it just opens and you can go up/down and left/right in it but when you hit OK or enter nothing is inserted. I am guessing that this is a way to make sure people using the intellisense instead when writing code. For me this will be a big change, I have used F5 for 13 years (that key is almost worn out 🙂 ) and suddenly it does not work the same way anymore. But I am sure once I get used to the intellisense it will be much better than the’old’ way.
Here are some examples of the intellisense feature;
Tables, functions, etc.. shows up the moment you start typing.
After selecting a table the intellisense displays the list of fields for you to select from, the fields narrows down while typing. Key fields has a small key next to them.
When you are entering an option value then the options shows up after you entered the ‘::’, this is very useful. Up until now I have always typed ‘::xx’ and then pressed F11 to compile to see the options through the error message, no need to do that anymore. 🙂
The above are just some examples of the features in the intellisense. One thing that I think is lacking is if you enter a ‘table.VALIDATE(‘ then the list of fields does not show up, you have to enter the table again first (like below) and then go back and delete the table name if you want it to look like standard NAV code. Would have been nice if the fields showed up directly.
Another great feature is that the table definition is shown if you hover over a table variable. The table definition shows the field names, types, and lengths as well as asterisks next to the primary key fields. This list of fields can also be resorted by clicking the headers.
In addition to the table definitions, you can also see the definitions of the functions and other types of variable if you hover over them. Hover over a function and you see the variables that the function should be called with and what its returning.
When you hit return to go to the next line it sometimes indents the next line and sometimes not, if it is after a ‘THEN’ it indents it for example. This is one thing to get used to I think. In the old editor it just went to the same indentation level as the line above, now you need to look at the screen a bit to know if you need to hit tab or not (or even backspace twice) when you enter a new line.
The Find and Replace function has been enhanced to handle regular expressions, which offers a more advanced way of searching. Not that I have missed this feature before but it seems useful. Apparently regular expressions are use in other programing editors, so why not in Dynamics NAV.
Some more information about how to build the search strings can be found by just googling ‘regular expressions’. My experience with this is limited, feel free to post a comment below if you have a useful example for this.
There is also a new option to zoom in and out in the editor. This is useful to adjust for high or low resolution screens. I have an ultra wide monitor with the resolution of 3440×1440, so for me zooming in could be useful (especially when I get older 🙂 ).
This is what I have found being the new and useful stuff in the new C/AL editor in Dynamics NAV 2016. If you prefer to still use the old one when programming in Dynamics NAV 2016, then you can do this by just adding ‘useoldeditor=Yes’ to the shortcut for the finsql.exe like below.
Not sure why you would do that, but there is this option.
Note that I will be at the Convergence 2015 EMEA in Barcelona next week talking and showing this new C/AL editor for Dynamics NAV 2016 along with other new features (like the recording of permissions) in the KCP Dynamics booth (booth number 3). If you are at the convergence, please visit booth number 3 and say hi (I believe we will be service Columbian coffee as well).
16 Comments
Leave your reply.