My take on GitHub Copilot for Business Central AL development had previously been that it was not as useful as it might be for more common languages (such as JavaScript, where I considered it to have more training data and therefore produce better results). I hadn’t used GitHub Copilot, but I had tried asking Copilot chat to create routines for me given a prompt or tell me how to do something, and the results were disappointing with either syntactically incorrect code or hallucinated features/libraries.
On December 18th, 2024, GitHub Copilot introduced a free tier, which meant I could try it out for real with my AL coding, and I have found it genuinely useful and time-saving in a number of use cases. Here are some examples.
New Enums
I had some enums to set up based on a list of possible values in a document. I found I could copy the list to my clipboard, Ctrl+drag an existing Enum in VS Code to create my starter, change the ID and name, and save it. Then select the value definitions and use the Modify with Copilot action and type “update to use these values” and paste my list. Copilot correctly rewrote all of my values to match the list, including using the Pascal-case values to set a correct English caption.
Renumbering Fields
Creating a new table based on a similar one, I inevitably start by copying an existing table (similar to the Enum approach) and removing fields I don’t want or changing the order. I could then select all the fields and using Modify with Copilot ask “renumber to be consecutive“. Works a treat. Maybe just “renumber” would have worked.
That’s Just Freaky!
I had a Codeunit and had a number of Global variables that I wanted to create “Setter and Getter” methods for (so I can pretend we have properties like a real programming language 🙂). I created my first GetVariableName procedure and auto-complete suggested the setters and getters for all of my other variables, and they were perfect.
Just the little things
Not to be overlooked are the suggested auto-complete where it adds a closing bracket and the semi-colon. Nice. Also, adding keys to a new table is nearly always correct in its suggestion.
Not so good
The areas that are not so good for me are when it tries to generate a lot of code (maybe suggests new fields for a table based on just the table name). Again, it’s kind of freaky that it suggests fields I really do need and some I hadn’t thought of, but I found I spent too long checking what it had written and also found I was tempted to keep fields I didn’t need in case they might be useful in the future. That’s not really a good thing to do, so I’m avoiding this scenario.
In Conclusion
Not only do I know I will continue to use this (and hopefully pick up lots more time-saving tricks), I cannot imagine wanting to go back to programming without Copilot. It would be like reverting back to life before IntelliSense. This is now part of how I work, and I will never go back.
