Automatically Create Procedure Stub / AL Navigator

Automatically Create Procedure Stub / AL Navigator

Last week I added a new feature to my Visual Studio Code Extension AL Navigator that makes it possible to create a procedure stub in AL. If you have not read my post about that extension yet, you can checkout this link. Here is the link to the newest extension on the VS Code Marketplace.

What Does It Do?

So what does this new feature do? It implements a functionality that I was strongly missing – detecting a procedure call and automatically creating the stub for it.

When And How To Use It?

Sometimes you will have situations, where you are programming something in a trigger or in a function. You already know, that you will split your code up in different functions because otherwise your code will be messy and hard to read.

You already write your procedure call and are then prompted with an error that the name “FunctionCall” does not exist in the current context.

I have to admit. When it comes to things like this, I am lazy. I do not want to write the stupid procedure stub if it is already clear what will be in there. We have 3 local variables (a, b, customer) and a procedure name “ShowExtensionExample”. This is where the extension comes into play. It provides you the possibility “Add Procedure Stub” with a quick fix lamp. This will automatically create the procedure stub in AL for you. If you prefer the keyboard, you can also just use the shortcut “CTRL” + “.”.

The procedure stub is now automatically created. It detected the used variables and added a TODO. This is especially cool if you use Gruntfuggly’s Todo Tree Extension.

A few final notes on this extension, what it is able to do now and what it will soon be able to do.

What It Can Do

  • Detect a not existing procedure call in the current file/object
  • Create a not existing procedure in the current file/object
  • Create a not existing procedure in a another object/file. If we take our example and want to call a not existing procedure in another codeunit, the stub creation is also possible. Something like this:
    • OtherCodeunit.ChangeMyIntegerValue(IntegerValue);
  • Detect local variables and add them to the stub
  • Detect global variables and add them into the stub
  • Detect the variable type of a return value and create procedure stub properly, something like this:
    LastEntryNo := GetLastEntryNo();
  • Write a TODO in the created stub

Hope some of you enjoy this new extension feature. Have a nice week!

2 thoughts on “Automatically Create Procedure Stub / AL Navigator

Leave a Reply

%d bloggers like this: