AL Object ID Ninja

  • Post comments:9 Comments
  • Reading time:13 mins read

One of the biggest obstacles to AL team development (is there any other kind?) is object IDs. IDs are supposed to be easy: just pick the next free one and off you go. AL Language even helps by suggesting the next available one through IntelliSense. But you are most likely not the only developer on your team. As soon as you add another developer to equation, and both of you use the built-in AL IntelliSense auto-suggest feature, you are inevitably heading towards object ID collision. The more developers there are, the more active your repository is, the more likely the collision.

Obviously, without some kind of a back-end that coordinates object ID assignment – preferably in real time – is absolutely necessary. And teams have come up with various solutions to this problem. They include:

  • “Who cares!”: the most heroic one, no object ID collision will ruin your day. Bring it on – you say! I’ll handle you – you say! These teams spend a lot of time resolving collisions post-factum.
  • Object “reservations”: you create an empty object of the desired type, push just that, create a PR that does nothing by that, and launch into the Hail Mary mode until your PR gets merged. The slower your validation pipeline is, the more likely it is that more than one developer will be saying their Hail Marys at the same time, and guess what – Mary will help one of them.
  • “Hey, folks”: you yell to announce to everyone that you are about to take an object ID. Or, in more advanced teams, you run a Teams team (uh, did I mention “team?”). This approach is not too robust, but generally yields better results than the above two.
  • Excel: the ways this tool gets used, geez. It’s a spreadsheet calculator, for Pete’s sake, but people have been using it for everything ranging from shopping lists to, well, object ID assignment sheets.
  • “When you have a hammer, every problem you see is a…” BC! The ways this tool gets used, too! Well, heck, yeah, isn’t it so freaking obvious that people will just create a BC app and deploy it internally so that everyone can use it. BC has nearly all facilities you need (that none of the above approaches does): primary key validation and concurrency. This is a very advanced stage in the evolution of object ID collision management solutions.
  • Automation. Yeah, baby! Now that there is a BC back end, and BC has APIs, let’s build an API that gives you next number, and then let’s do some front-end that fetches that from the back end, and then let’s somehow embed into VS Code. There is at least one tool that I know of, that does exactly this. And good that I didn’t know of it that Saturday morning nine days ago, because I would have zero motivation to take this evolution one big step further.

This is where AL Object ID Ninja joins the show! It’s zero-configuration, crazy-fast, mind-bogglingly simple solution for no-collision object ID assignment in AL. If you haven’t already (and if you are using Waldo’s AL Extension Pack, chances are you already have) go fetch yourself a copy.

(more…)

Continue ReadingAL Object ID Ninja

Conditional directives

  • Post comments:0 Comments
  • Reading time:2 mins read

One of the new features of the AL compiler that arrived with 2020 Wave 2 is Precompiler directives. This is nothing spectacular, programming languages had these kinds of things since the dawn of programming languages, and now we have them too.

The biggest thing, though, is that on their surface, just like so many other features (cough! interfaces, cough, cough, interfaces) you can’t really grasp their full power just by reading the documentation available.

(more…)

Continue ReadingConditional directives

A couple of ideas for HttpClient

  • Post comments:1 Comment
  • Reading time:18 mins read

When invoking any REST web services, a lot of AL code mostly looks like this:

procedure CallRESTFoo()
var
    Client: HttpClient;
    Response: HttpResponseMessage;
    Body: Text;
    Json: JsonObject;
begin
    Client.Get('https://foo.bar/', Response);
    Response.Content.ReadAs(Body);
    Json.ReadFrom(Body);
    // Process JSON body of the response...
end;

Of course, there are more things there, like headers or perhaps calling HTTP POST (or another method) instead of GET, but when you strip it down to the bones, the chunk above is what remains.

Today’s post is a follow up for my HttpClient Patterns live session on http://vjeko.live/ and as I promised, I am providing the text-only version for those who prefer reading to watching.

(more…)

Continue ReadingA couple of ideas for HttpClient

Fun with Interfaces

  • Post comments:4 Comments
  • Reading time:2 mins read

Today I've streamed the Fun with Interfaces video blog at https://www.youtube.com/watch?v=QSMHL32c5mg and the recording is now published online. This was the first session I ever delivered about interfaces, and I…

Continue ReadingFun with Interfaces

How to replace DotNet in AL

  • Post comments:8 Comments
  • Reading time:9 mins read

A lot of us still have a ton of C/AL code sitting around in existing databases that sooner or later will have to be moved into AL. A lot of us also have a ton of AL code using DotNet that we want to be able to run in Microsoft’s cloud (that is: not on-prem). And I guess most of us don’t want to maintain a DotNet-less and DotNet-ful versions of our code.

Sooner or later, you’ll want all of DotNet out of your AL. Even if you are a seasoned .NET developer, you’ll want all DotNet out of AL.

Anyway, when you need to replace DotNet, what options do you have? Let’s take a look at all possible paths.

(more…)

Continue ReadingHow to replace DotNet in AL