Stop staring at a blank .al file—let Copilot draft the boilerplate while you focus on designing rock-solid business logic.
Why GitHub Copilot for Business Central?
- Native IDE support. Copilot lives inside Visual Studio Code right next to the AL Language extension, so suggestions appear inline as you type. Visual Studio Code
- Symbol-aware completions. Since April 2025 you can let Copilot look up downloaded symbol packages to understand table keys, page parts, or event publishers before it generates code. Microsoft Learn
- Time savings. Microsoft’s own telemetry shows Copilot users finish coding tasks 55-70 % faster on average across languages—including AL.
- Contextual chat. Ask “Why does my OnInsert() trigger fail validation?” and Copilot Chat walks you through the logic with references to the exact lines.
Setup ChecklistStep | Action | Notes |
1 | Install VS Code (v≥ 1.102) | New Manage Language Model Access UI lets you whitelist Copilot per workspace. Visual Studio Code |
2 | Install AL Language Extension (v≥ 11.x) | Adds .al syntax, publishing, symbol download. |
3 | Install GitHub Copilot & Copilot Chat extensions | Requires GitHub account (Free trial, Individual, or Business). |
4 | Enable Use symbol packages as context in settings.json | Boosts accuracy for prompts that reference existing objects. |
5 | Sign in & choose plan | Business plan adds policy enforcement & telemetry controls. |
Prompt-Engineering 101GitHub Docs suggest three golden rules for effective prompts: intent, context, constraints. GitHub DocsVisual Studio Code// Vague// "Create a table."// Structured/*Goal: Table for employee leave balances.Fields: Employee No. (PK), Leave Code, Balance (Decimal 8,2), Last Updated (Date).Add OnValidate() on Balance to prevent negatives.*/Quick Tips- Start with comments, then hit Tab to accept Copilot’s code.
- Reference existing object IDs (50100.. range) so Copilot respects your numbering.
- Iterate. Press Ctrl + Enter to open Chat and refine: “Change field 30 to AnnualBalance and add a FlowField for EntitledDays.”
AL Prompt Recipes by Object Type
Below are copy-paste-ready comment prompts you can drop into VS Code. Copilot will propose full AL stubs—edit as needed before pushing to your repo.
Table Objects
// Create table 50110 "Customer Ledger Summary" with
// - Customer No. (PK, Code 20)
// - Open Entries (Decimal 18,2)
// - Total Due (Decimal 18,2) FlowField CalcSum("Cust. Ledger Entry"."Amount")
// Quick TP: Add Init() to set Open Entries to 0.
Why it works: Lists object type, ID, name, field specs, and one trigger.
Card & List Pages
/* Build a Card page for table 50110.
Include a FastTab "Statistics" with Open Entries and Total Due displayed as editable=false.
Add action "Show Ledger" to run Page 25 filtered by current "Customer No." */
Reports
/*
Report 50135 "Sales by Country"
- DataItem: "Sales Invoice Header"; filter Posting Date between StartDate..EndDate
- Group by Country/Region Code
- Layout: RDLC; show Total Sales, Total Profit
*/
Codeunits & Events
// Codeunit 50180 "Customer Bulk Update"
// Procedure Run(CustomerNos: List of [Code[20]]; NewBlocked: Boolean)
// For each customer: modify field Blocked := NewBlocked.
// Raise IntegrationEvent OnCustomerUpdated(Cust: Record Customer).
Queries
/*
Query 50190 "Item Availability by Location"
Data Source: "Item Ledger Entry"
Columns: Item No., Location Code, SUM(Quantity)
Order by Item No., Location Code
*/
Test Codeunits
// Test codeunit 50200 "Item-Journal Tests"
// Scenario: Posting a positive adjustment increases inventory value.
// Arrange: Create Item 1896-S; Act: Post Item Journal Qty=5; Assert: Item.GetInventory() = 5.
Advanced Copilot Tricks
- Symbol search as context – Press ⌘ + P > AL: Find Symbol in App Package then ask Copilot “Generate a PageExtension for this table with additional cues.”
- Remote workspace index – Build once with GitHub Copilot: Build Remote Index to speed up suggestions in large AL repos. Visual Studio Code
- Chat-driven refactoring – Highlight a 100-line trigger, open Copilot Chat, and prompt “Refactor into smaller procedures following single-responsibility principle.”
- Explain legacy code – // explain comment before an old OnValidate() and Copilot annotates each step.
Quality & Security Guardrails- Run the AL Compiler (Ctrl + Shift + B) after every suggestion—Copilot can hallucinate field names.
- Enable code analysis ruleset to flag unused variables and missing captions.
- Review licensing-sensitive code—Copilot sometimes mimics GPL snippets.
- Unit-test everything; Copilot makes it easy to scaffold test codeunits, so no excuse!
- Document generated code; a summary comment clarifies that Copilot contributed.
Common Pitfalls & FixesPitfall | Symptom | Fix |
Ambiguous prompt | Generates wrong data type or missing caption | Add explicit field types, captions, and tooltips in prompt. |
ID collisions | Copilot reuses 50000 IDs | Reserve ID ranges in app.json; mention them in the prompt. |
Hallucinated functions | Suggests nonexistent system functions | Validate against AL docs; ask Copilot “Is this API real?” |
Over-eager completion | Inserts code while you type | Use Escape to dismiss; disable inline for large files. |
Takeaways & Next Steps
GitHub Copilot is more than autocomplete; with well-crafted prompts it becomes a context-aware AL architect that drafts tables, pages, reports, and tests in seconds. Combine the recipes above with the latest symbol-aware context features to slash development time and boost code quality.
Ready to master Copilot?
GitHub Copilot remains the top enterprise coding LLM in 2025 for its IDE integration and real-time assistance.Happy coding—and may your prompts be ever precise!