Performance Profiling Tests with AL Test Runner
Mar01

Performance Profiling Tests with AL Test Runner

This is a feature that has been in AL Test Runner for a months now but I haven’t got round to blogging about it. I haven’t done much blogging or work on AL Test Runner for a while now. I started a new job at the start of the year and had more important stuff keeping me occupied, but Johannes (https://github.com/jwikman) has prompted me into some action with some contributions recently – thanks… Continue Reading...

Read More
Using the Dynamic Data Type in KQL
Aug22

Using the Dynamic Data Type in KQL

Intro Lately I’ve been working more with telemetry, Application Insights, the excellent Power BI report and samples from Microsoft and writing a little KQL. Back in the days when you actually knew where your SQL server was I used to write a lot of ad-hoc SQL for analysis or troubleshooting so getting into KQL has been nice. KQL sort of looks like SQL…but with the SELECT and FROM clauses… Continue Reading...

Read More
Flagging How Your Code Got Called
Aug09

Flagging How Your Code Got Called

Sometimes it would be useful to know how your code has been reached. For example, how and why is this sales line being inserted, or this sales order released? You might want to react differently in your code depending on the situation. In my case I wanted to know if my code has been reached because a configuration package is currently being applied. In the end we decided this wasn’t needed… Continue Reading james’s...

Read More
Tip: Out-ExcelClipboard in PowerShell
May16

Tip: Out-ExcelClipboard in PowerShell

From time to time I want to get some result from a PowerShell command into Excel. Unless I’m missing something, there isn’t a great option to do this in standard PowerShell. I know that you can use Export-Csv or Export-Clixml and then open the file in Excel. I know you can use Out-GridView and then copy and paste from there into Excel (albeit without the column headings). You can also use… Continue Reading...

Read More
Trigger a Power Automate Flow from Business Central for a Selected Record
Nov22

Trigger a Power Automate Flow from Business Central for a Selected Record

Intro This is my first stop on the Power Platform learning train. As I mentioned in the first post, this seems like a significant moment to me. Over the last few versions users have had more control over the web client. Between the Personalise and Design options you can tweak a lot of the elements on a page. If you wanted to introduce some logic you could do that through Power Automate…. Continue Reading james’s Article on...

Read More
Getting Onboard with Power Platform as a Business Central Developer
Nov16

Getting Onboard with Power Platform as a Business Central Developer

Intro One of the things that I wanted to come away with from Directions EMEA last week was a better overview of the Power Platform. What is it? What can we do with it? When should we use it? How does it fit into the overall solutions that we are designing for our Business Central customers? If you’re anything like me then you’ve been aware that you need to get on the Power Platform… Continue Reading james’s...

Read More
Tip: Share a Git Hooks Directory Across Your Repositories
Sep07

Tip: Share a Git Hooks Directory Across Your Repositories

TL;DR git config –global core.hookspath ‘<path to hooks directory>’ Sharing Hooks Across Repos I posted before about using a pre-commit hook to check that I’m not committing anything that I really shouldn’t be (anything I’ve tagged with //DONOTCOMMIT). Hooks are specified in the .git/hooks directory. That’s great, a git repository is completely contained within its parent folder,…...

Read More
Spare Your Blushes with Pre-Commit Hooks
Aug23

Spare Your Blushes with Pre-Commit Hooks

It’s Summer (at least in the northern hemisphere), hooray. You’ve booked some time off, wrapped up what you were working on as best you can, committed and pushed all your code, set your out-of-office and switched off Teams. Beautiful. When you come back you flick through your messages to catch back up. What’s this? Some muppet commented out some vital code and pushed their changes? Who?… Continue Reading...

Read More
Execute JavaScript with WebPageViewer for Business Central
Jul11

Execute JavaScript with WebPageViewer for Business Central

TL;DR The WebPageViewer add-on has an overload to accept some JavaScript. You can use that to execute arbitrary script locally. WebPageViewer.SetContent(HTML: Text; JavaScript: Text); Executing JavaScript with WebPageViewer JSON Formatting This post starts with me wanting to format some JSON with line breaks for the user to read. It’s the response from an Azure Function which… Continue Reading james’s Article on...

Read More
Tip: Editing RapidStart Configuration Package Files
Jun17

Tip: Editing RapidStart Configuration Package Files

TL;DR Extract the package with 7-ZipOpen the extracted file in a VS Code / Notepad++ / text-editor-of-choiceEdit the xml as requiredUse 7-Zip to compress in gzip format Editing Config Packages Sometimes you might want to edit a config package file without having to import and export a modified copy from BC. In my case I wanted to remove the Social Listening Setup table from the… Continue Reading james’s Article on their...

Read More
Pre-Releases & GitHub Actions for Visual Studio Code Extensions
May02

Pre-Releases & GitHub Actions for Visual Studio Code Extensions

Intro This post is going to be a bit of a brain dump about developing my VS Code extension, branching strategy for pre-releases and releases and using GitHub actions to stitch it all together. If you’re only here for the AL / Business Central content then you might want to give this one a miss. Then again, Microsoft are increasingly using GitHub for AL projects themselves (e.g. AL-Go for… Continue Reading james’s...

Read More
AL Test Runner Pre-Release Version
Apr05

AL Test Runner Pre-Release Version

TL;DR There is now a pre-release version of the AL Test Runner extension for Visual Studio Code. It will have the latest (and possibly unstable) features. Pre-Releases VS Code recently added support for pre-release versions of extensions. You can install a pre-release by clicking on the “Switch to Pre-Release Version” button from the extension details within VS Code. See

Read More
Tip: Test for Tables Missing from Permission Sets
Mar07

Tip: Test for Tables Missing from Permission Sets

In PowerShell: $tablesInPermissionSets = @() $permissionSets = gci . -Recurse -Filter ‘*.al’ | ? {(gc $_.FullName).Item(0).startsWith(‘permissionset’)} $permissionSets | % { $content = gc $_.FullName -Raw [Regex]::Matches($content, ‘(?<=tabledata ).*(?= =)’) | % { $tablesInPermissionSets += $_.Value } } $tablesInTables = @() $tables = gci . -Recurse… Continue Reading james’s...

Read More
JSON References
Feb28

JSON References

TL;DR JSON types reference their value in memory, not the actual value. The below is snipped from https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/jsonobject/jsonobject-data-type Be careful making JSON types equal to one another. When you do that you copy the reference, not the value. This caught me out. Example 1 I’m implementing… Continue Reading james’s Article on...

Read More
Tip: Install all Apps in a Folder to a Container
Feb03

Tip: Install all Apps in a Folder to a Container

Intro I do this fairly often to prep a new (local) container for development. The script needs to be run on the Docker host and assumes that the PowerShell prompt is already at the folder containing the apps (or apps in child folders) you want to install. Use the dev endpoint if you are going to want to publish the same apps from VS Code into the container. Or publish into the global… Continue Reading james’s Article on...

Read More
Tip: Get Current Callstack with a Collectible Error
Jan19

Tip: Get Current Callstack with a Collectible Error

The Code codeunit 50104 “Get Callstack” { SingleInstance = true; [ErrorBehavior(ErrorBehavior::Collect)] procedure GetCallstack() Callstack: Text var LF: Char; begin LF := 10; Error(ErrorInfo.Create(”, true)); Callstack := GetCollectedErrors(true).Get(1).Callstack; exit(Callstack.Substring(Callstack.IndexOf(Format(LF)) +… Continue Reading james’s Article on their blog Tip: Get Current Callstack with...

Read More
Part 4: (Slightly) More Elegant Error Handling in Business Central
Jan17

Part 4: (Slightly) More Elegant Error Handling in Business Central

Collectible Errors In part 3 we had a look at the new platform feature, collectible errors. Long story short: it makes scenarios where you want to collect and display multiple errors together (e.g. checking journal lines) much easier to code and read, no messing around with if Codeunit.Run then, read the post if you’re interested. The only thing that let the team down was the horrible… Continue Reading james’s...

Read More
Tip: List-Commits
Jan11

Tip: List-Commits

function List-Commits { cd ‘C:Git’ $Commits = @() Get-ChildItem . -Directory | % { cd “$_” if (Test-Path (Join-Path (Get-Location) ‘.git’)) { $Commits += git log –format=”$($_)~%h~%ai~%s~%an” | ConvertFrom-Csv -Delimiter ‘~’ -Header (‘Project,Hash,Date,Message,Author’.Split(‘,’)) } cd .. } $Commits | ? Author -EQ “$(git config –get...

Read More
Part 3: (Slightly) More Elegant Error Handling in Business Central
Dec13

Part 3: (Slightly) More Elegant Error Handling in Business Central

Intro This is a continuation of a series of posts started around a year ago – you can find the old posts here if you are interested. Briefly, the goal is this. I’m posting a journal and there are several checks that I need to perform on each line before they are posted. Instead of stopping and showing the first error I want to validate all of the lines and show all of the errors to the… Continue Reading james’s...

Read More
Tip: Remove-BranchesWithUpstreamGone
Oct20

Tip: Remove-BranchesWithUpstreamGone

Wait, I Thought I Deleted That Branch? One of the things that I found counter-intuitive when I was getting started with Git is that when branches are deleted on the server they are still present in your local repository, even after you have fetched from the server. We typically delete the source branch when completing a pull request, so this happens a lot. Usually, once the PR has been… Continue Reading james’s Article on...

Read More
Is GitHub Copilot Any Good for Business Central Development?
Sep13

Is GitHub Copilot Any Good for Business Central Development?

TL;DR No. At least, not yet. Maybe later. But even then, maybe not. Intro For now this is necessarily a simple, first impressions post about GitHub Copilot. I’ve used it for a few weeks, tweeted enthusiastically in the first couple of days’ use and have now disabled it. What is it, how does it work, what’s good, what’s not so good? What is GitHub Copilot? Your AI pair… Continue Reading james’s...

Read More
Test Explorer in Visual Studio Code
Sep01

Test Explorer in Visual Studio Code

The July 2021 release of Visual Studio Code (1.59) introduced a new testing API and Test Explorer UI. From v0.6.0 this API is used by AL Test Runner. Test Explorer Demo Improvements UI The biggest improvement is the Test Explorer view which shows your test codeunits, their test methods and the status of each. Hovering over a test gives you three icons to run, debug or open… Continue Reading james’s Article on their blog...

Read More
Using Code Coverage in Business Central Development
Jul20

Using Code Coverage in Business Central Development

Intro Sample code coverage summary In the latest version of AL Test Runner I’ve added an overall percentage code coverage and totals for number of lines hit and number of lines. I’ve hesitated whether to add this in previous versions. Let me explain why. Measuring Code Coverage First, what these stats actually are. From right to left: Code Coverage 79% (501/636) The total… Continue Reading james’s Article on...

Read More
Get Errors from a Docker Container Event Log
Jun10

Get Errors from a Docker Container Event Log

“You cannot sign in due to a technical issue. Contact your system administrator.”Business Central Terrific. This is in a local Docker container, so I am the system administrator. Give me a second while I contact myself… …nope, myself didn’t know what the problem was either. It could be that the license has expired, maybe there is something wrong with the tenant, the service tier… Continue Reading...

Read More
Show Table Data from AL Test Runner
May08

Show Table Data from AL Test Runner

Why? If you are writing Business Central automated tests then you are probably creating some data as part of those tests. Sometimes it can be useful to see the records that have been created, especially if you are trying to create the correct scenario for the GIVEN part of your test and are experimenting with the library codeunits in that part of the system. Of course you can debug your… Continue Reading james’s Article on...

Read More
Increase ODataServicesOperationTimeout for Longer Debugging
Apr22

Increase ODataServicesOperationTimeout for Longer Debugging

TL;DR Invoke-ScriptInBCContainer [container name] {Set-NavServerConfiguration bc -KeyName ODataServicesOperationTimeout -KeyValue 00:20:00 -ApplyTo All} Timeout Error If you use AL Test Runner to debug your tests then you are using the OData services to run the test in the background. OData calls have a timeout that is determined by the ODataServicesOperationTimeout key in the service… Continue Reading james’s Article...

Read More
Upgrade Your StrMenus to Confirmation Pages
Apr09

Upgrade Your StrMenus to Confirmation Pages

Exhibit A: StrMenu when posting a sales document Prompting the User Sometimes we want to ask users to make a decision before executing some business logic. Often we just want a yes/no answer and can use a simple Confirm. But what if you can’t phrase the question to give a yes/no answer? Or if there are more than two options for the user to select between? Traditionally we’ve used… Continue Reading james’s...

Read More
Using the WebPageViewer Add-In For Business Central
Mar29

Using the WebPageViewer Add-In For Business Central

Since the introduction of pages, and the deprecation of forms, we have had a fixed set of page types that we can create and a fixed set of controls that we can use on those pages. In the main, that’s a good thing. An appropriate control (text entry, date picker, checkbox etc.) is automatically used depending on the data type of the field, developers need to spend less time on the UI and the… Continue Reading james’s...

Read More
Measuring Code Coverage in Business Central with AL Test Runner
Feb07

Measuring Code Coverage in Business Central with AL Test Runner

v0.5.0 of AL Test Runner adds some capability to measure code coverage per object and highlight the lines of code that were hit in the previous test run. This is an example of what we’re aiming for. Running one or more tests, seeing the list of objects and the percentage of their code lines that were hit, opening those objects and highlighting those lines. This should help identify objects… Continue Reading james’s...

Read More
Extending Item Tracking in Business Central
Jan30

Extending Item Tracking in Business Central

I’ve been pretty quiet on the blogging front for the last few months – settling in to a new team and a new role. For the first post of 2021 what better topic than Item Tracking? Let’s be honest, the Item Tracking Lines page is a mess. Over 3,000 lines of code, tonnes of global variables and more than 60 methods. I don’t think the fundamental design of the page has changed much since it was… Continue...

Read More
Part 2a: (Slightly) More Elegant Error Handling in Business Central
Sep28

Part 2a: (Slightly) More Elegant Error Handling in Business Central

One of the underrated advantages to doing a little blogging is that you can write about a subject you know a little about and have people who actually know what they are talking about reply to tell you a better way to do it. There’s probably a minimum threshold of credibility on the subject you need in order for people to post serious replies. If I posted some nonsense about my keyhole… Continue Reading james’s...

Read More
Part 2: (Slightly) More Elegant Error Handling in Business Central
Sep15

Part 2: (Slightly) More Elegant Error Handling in Business Central

Part 2 of the series that I said that I was going to write has been a long time coming. If you don’t know what I’m talking about you might want to read the first post in the series here. Unfortunately it is possible that this series reflects the functionality that it is describing: full of early promise, but on closer inspection a little convoluted and disappointing. I’ll leave you to be the… Continue Reading...

Read More
Debugging Business Central Tests with AL Test Runner
Jul30

Debugging Business Central Tests with AL Test Runner

TL;DR Install the Test Runner Service app (see https://github.com/jimmymcp/test-runner-service; direct download of the app file from here) or use the “Install Test Runner Service” command from VS Code to install into the Docker container specified in the config fileSet the URL to the test runner service in the testRunnerServiceUrl key of the AL Test Runner config fileDefine a debug… Continue Reading james’s...

Read More
Tip: Evaluating DateTime with Type Helper
Jul21

Tip: Evaluating DateTime with Type Helper

Dates. What a nightmare. Day/Month/Year? Month/Day/Year? 24 hour time? 12 hour time? It’s almost enough to make you sympathetic to the idea of decimal time…almost. Type Helper codeunit to the rescue. It has a method to allow you to evaluate the text of a date, time or datetime into the corresponding type according to a format that you specify. AVariant := DateResult; FormatString :=… Continue Reading james’s...

Read More
Record Rename/Modify Considerations
Jul14

Record Rename/Modify Considerations

TL;DR Use table extensions to extend the OnModify trigger rather than OnBefore/AfterModify subscriptions where possible. If you must use subscribers then be aware of some of the unexpected situation they are called in. One of those situations is when a related table has been renamed. The Modify events are thrown in secondary tables e.g. if an Item record is renamed than all of its Item… Continue Reading james’s Article on...

Read More
(Slightly) More Elegant Error Handling in Business Central
Jul03

(Slightly) More Elegant Error Handling in Business Central

This is an intro post to the Error Message Mgt. codeunit and related objects. NAV has never brilliant when it comes to error handling, for a couple of reasons. The error messages themselves sometimes leave a lot to be desiredThe whac-a-mole nature of fixing multiple errors by finding one at a time and attempting to post/register again There isn’t a lot we can do about the standard error… Continue Reading james’s...

Read More
Share Docker Containers With VS Code Live Share
Jun05

Share Docker Containers With VS Code Live Share

If you weren’t working remotely before 2020 then we’ve all had to guess used to it this year. Collaboration tools like Teams are invaluable for keeping up with teammates during the day, discussing work and bouncing ideas and banter off each other. Video calls, screen sharing, chat, shared documents, gifs – that’s all great – but not quite a replacement for sitting at the same desk and looking…...

Read More
Tip: Octopus Merges in Git
May21

Tip: Octopus Merges in Git

If you occasionally glance at my blog you might have noticed that I am a big fan of pull requests as served up by Azure DevOps (exhibit A). I briefly described our typical branching strategy here, including how and why we use pull requests. I love it. Writing, testing and reviewing discrete pieces of development independently of one another helps spread the work around the team and prevent… Continue Reading james’s Article...

Read More
Testing Internal Functionality
May19

Testing Internal Functionality

Internal Access Modifier We’ve had access modifiers in Business Central for a little while now. You can use them to protect tables, fields, codeunits and queries that shouldn’t be accessible to code outside your app. For example, you might have a table that contains some sensitive data. Perhaps some part of a licensing mechanism or internal workings of your app that no one else should… Continue Reading james’s...

Read More
Getting Started with Git Hooks
May11

Getting Started with Git Hooks

Git hooks have been on my “to mess about with and learn a little some day” list for a while. It’s the old conundrum: I might use them if I knew what they could do, but I’m not going to learn about them until I’ve got a use for them. Chickens-and-eggs for developers. The Problem Until recently, that is. I wondered: What is the best way to save a different launch configuration in VS… Continue Reading...

Read More
“Discrete Business Logic” implements Interface
Apr28

“Discrete Business Logic” implements Interface

If you’ve read anything about what is new in BC16 for developers then you’ll have seen that AL now supports interfaces (fanfare). No more convoluted workarounds with events – at least once our customers have upgraded. I won’t explain what interfaces are and how to use them in AL. You can read the release notes here or blog posts like this and this. Instead I’m going to share some thoughts… Continue...

Read More
Performance of Test Code
Apr16

Performance of Test Code

Let’s talk about the performance of the test code that we write for Business Central. What do I mean by “performance” and how can we improve it? Defining “Performance” Obviously, before we set out to improve something we need to have an idea of what it is we’re trying to optimise for. I’m coming to think of the performance of test code in a couple of key ways: How easy/quick is it to…...

Read More
Tip: Case Insensitive Glob Patterns
Apr08

Tip: Case Insensitive Glob Patterns

I must admit I hadn’t heard of glob patterns until seeing some settings in VS Code that use them. They are a way of defining a pattern that matches one or more files and folders. For example, the Text Editor section of the settings (UI) in VS Code allows you to exclude files and folders from the file explorer with glob patterns and gives you this useful link for more information. My AL… Continue Reading james’s...

Read More
Managing Business Central Development with Git: Platforms
Apr03

Managing Business Central Development with Git: Platforms

Another post about Business Central development and Git. Maybe the last one. Who knows? Whatever your precise circumstances, if you are developing apps for Business Central you have to be mindful of the differences between BC versions and how it affects your app. If you are only developing for SaaS you might only care about the current and next version. If you are developing and… Continue Reading james’s Article on their...

Read More
Problem with Case Statement in Business Central 13
Mar24

Problem with Case Statement in Business Central 13

This is a a pretty niche post. Hopefully this problem only exists in a specific set of circumstances, in Business Central v13, but we wasted enough hours of our lives chasing it down yesterday that I thought I’d share it. Consider this case statement: i := 3; test := true; case i of 1: exit(‘i equals 1’); 2: if test then exit(‘i equals 2, test is true’) else if… Continue Reading james’s...

Read More
Managing Business Central Development with Git: Branching Strategy
Mar19

Managing Business Central Development with Git: Branching Strategy

The last few posts have been about manipulating the history of your Git repository, getting comfortable tools like rebase, reset, cherry-pick and commit –amend. That’s all geared towards trying to create a history which is more than just a record of stuff that happened but tells a story of the development of your app that is useful for your colleagues and your future self. This post is on… Continue Reading...

Read More
Tip: Format AL Files OnSave in Visual Studio Code
Mar02

Tip: Format AL Files OnSave in Visual Studio Code

Maybe everyone else is already doing this and I’m just slow on the uptake but Visual Studio Code has options to automatically format files at various points. The AL extension for VS Code provides a formatter for .al files. You can run it manually with the Format Document command (Shift+Alt+F). This inserts the correct number of spaces between parameters and brackets, indents lines… Continue Reading james’s Article on...

Read More
Managing Business Central Development with Git: Branches
Feb25

Managing Business Central Development with Git: Branches

Obligatory Preamble I wasn’t really intending to write this post. If you want training materials for learning the basic concepts of Git then there is tonnes of great free content around on blogs and YouTube channels. I was going to share some thoughts about our branching strategy but thought I’d write a little about manipulating branches first. Amble When I was new to Git and trying… Continue Reading james’s...

Read More
Managing Business Central Development with Git: Rebasing
Feb19

Managing Business Central Development with Git: Rebasing

This is part two of a series about using Git to manage your Business Central development. This time – rebasing. It seems that rebasing can be something of a daunting subject. It needn’t be. Let’s start with identifying the base of a branch before worrying about rebasing. Example Repo Imagine this repository where I’ve created a new branch feature/new-field-on-sales-docs to do some… Continue Reading...

Read More
Managing Business Central Development with Git: Amending History
Feb13

Managing Business Central Development with Git: Amending History

Preamble This is the start of a series of posts about managing AL development with Git. I don’t profess to be a Git expert and much of what I write about will not exclusively apply to Business Central development. This is a collection of approaches I’ve found to be useful when it comes to managing our source code. Take what you will, discard the rest, vociferously argue with me if you feel… Continue Reading...

Read More