CRS Language Extension – Boost Your Productivity with AL/BC

CRS Language Extension – Boost Your Productivity with AL/BC

This is the third post of the blog post series “Boost Your Productivity with AL and Business Central”. If you want to know more about what this series is about and why I created it, you can checkout this post.

The CRS Language Extension offers a few features that can make your life a lot easier when developing in AL. In this post, I will talk about the features that I use the most:

  • Rename Files
  • Snippets for various situations

CRS Language Extension has a lot of functionality but today we will focus on the most important ones. If you want to know more about the other features, feel free to check out the description of the extension.

Probably the most frequently used functionality is “Renaming File”. This functionality alone makes the installation worthwhile. For this reason, it is best to talk about it first.

CRS Language Extension – Renaming/Reorganizing Files

If you’ve named your files yourself so far, I’ve got some good news for you right now – it’s not necessary. From now on you can let the CRS Language Extension do that for you.

The extension renames the file names according to Microsoft guidelines. Currently, the naming follows the following structure, which may change in the future:

<ObjectNameExcludingPrefix>.<FullTypeName>.al

For extensions this naming is currently used:

<ObjectNameExcludingPrefix>.<FullTypeName>Ext.al

The latest Best Practices for AL can be found here.

If you have used the CRS Language Extension in the past, I strongly recommend that you read this blog post by Waldo. Due to new naming conventions from Microsoft, there will be stricter rules for naming in the future. Therefore, your previous file names may have to be renamed. There are a few things to consider that Waldo explains in more detail in his post.

Available CRS Language Extension Functions

Let’s take a closer look at the functions of the extension. If we open Visual Studio code and execute the keyboard shortcut Ctrl + Shift + P (“Show All Commands”), we can see the list of available CRS functions. For this we type “CRS”.

CRS functions

The following four commands jump out at us:

  • Rename – All Files
  • Rename – Current File
  • Reorganize – All Files
  • Reorganize – Current File

Renaming

Okay. Let’s start with the second function “Rename – Current File”. Why the second one? Because the first function “Rename – All Files” does exactly the same as the second one – just for all files instead of just the currently opened one.

I have created a new project. In this project there is an AL file “examplefile.al” for table 50100.

Example file

We use the keyboard shortcut Ctrl + Shift + P to open the command window and execute the function “Rename – Current File”.

This will automatically rename my file to “MyTable.Table.al”.

Note: If you have changed the value of the field “CRS.FileNamePattern” in the settings.json file, the extension will rename your file according to the specified pattern. You can also read about the best settings in the settings.json file in Waldo’s blog post.

Update 25.04.2020: Also make sure to read this post by waldo which includes an update on the best settings in the settings.json file.

Reorganize

Afterwards I rename the file once again to “examplefile.al”. This time we use the function “Reorganize – Current File”.

Reorganize Current file

This renames the file and moves it to the “src\table” folder.

Table Folder

The function “CRS – Reorganize All Files” would do the same for all files.

AL Snippets

The CRS AL Language Extension comes with many snippets. You can get a good overview of the snippets by opening an AL file and typing “twaldo” in the editor. It is best to test the different snippets yourself.

waldo snippets

Some of the snippets can save you a lot of time. Especially if you are still used to programming with C/AL, you probably type most of the keywords completely by yourself. There are some snippets like “twhile”, “twithdo” etc. which can save you a lot of work.

With the help of these snippets the structure is already given to you and you can jump through the different snippets with the Tab key. On the following screenshot I use the snippet “twhile(waldo)”.

The snippet directly creates a complete while block for me. Very useful for programming!

twhile snippet
twhile snippet used

Another snippet has caught my eye in the last few days – “tProcedureFromClipboard”. It takes the text from your clipboard and creates a function for it. Excellent!

For this we take the following sample code:

sample code

Then we copy the two lines of code between begin and end.

We jump to an empty place within our AL file and call the snippet “tProcedureFromClipboard”

tprocedurefromclipboard

This is the result:

created procedure

That’s it! Hope you got something here for yourself. See you next time.

2 thoughts on “CRS Language Extension – Boost Your Productivity with AL/BC

Leave a Reply

%d bloggers like this: