Skip to content

Quick Start Guide - AL Development Collection

⚠️ AI-Generated Content Disclaimer: This toolkit uses GitHub Copilot and generative AI to assist in AL development. Agent responses and code generation results may vary based on context, model versions, and user inputs. Always review and test generated code thoroughly before deploying to production environments.

AI-powered AL development in 2 simple steps for Microsoft Dynamics 365 Business Central.


πŸš€ Quick Installation (5 minutes)

1. Install from Marketplace: Search "AL Development Collection"
2. Command Palette: AL Collection: Install Toolkit to Workspace
3. Reload VS Code

Option 2: NPM

npm install github:javiarmesto/AL-Development-Collection-for-GitHub-Copilot
npx al-collection install

Option 3: Manual

git clone https://github.com/javiarmesto/ALDC-AL-Development-Collection-for-GitHub-Copilot.git
cd AL_Copilot_Collection
node install.js install [your-al-directory]

After installation: Reload VS Code (Ctrl+Shift+P β†’ Developer: Reload Window)


πŸ“‹ Two Main Tools

1️⃣ al-architect β†’ Design the solution

Use when: You need to plan a new feature

Use al-architect mode

I need to build a sales approval system with:
- Approval levels by amount
- Email notifications
- Audit trail

Result: Complete architecture, data model, integration points

2️⃣ al-conductor β†’ Implement with TDD

Use when: You have the design and want production-ready code

Use al-conductor mode

Implement the approval system designed by al-architect

Result: Complete AL code, 100% tests, automatic documentation


🎯 Basic Workflow

For Simple Features (🟒 1-2 objects)

Step 1: Describe what you need
Step 2: Copilot generates the code (with auto-guidelines)
Step 3: @workspace use al-build β†’ Deploy

Example: "Add email validation to Customer table"


For Moderate Features (🟑 3-6 objects)

Step 1: Use al-architect mode β†’ Design
Step 2: Use al-conductor mode β†’ Implement with TDD
Step 3: @workspace use al-permissions β†’ Permissions
Step 4: @workspace use al-build β†’ Deploy

Example: "Customer loyalty points system"

Time: 2 hours (vs 2 days manual)


For Complex Features (πŸ”΄ 7+ objects)

Step 1: Use al-architect mode β†’ Complete architecture
Step 2: Use al-api mode (if APIs needed)
Step 3: Use al-conductor mode β†’ Multi-phase implementation
Step 4: @workspace use al-performance β†’ Validation
Step 5: @workspace use al-build β†’ Deploy

Example: "Integration with external payment gateway (OAuth + webhooks)"

Time: 1-2 days (vs 1-2 weeks manual)


πŸ’‘ What's My Complexity?

🟒 Simple (Directly with Copilot)

  • βœ… Limited scope β€” isolated change
  • βœ… Field validation or page extension
  • βœ… Single implementation phase
  • βœ… No integrations needed

🟑 Moderate (al-architect + al-conductor)

  • βœ… Moderate scope β€” multiple related areas
  • βœ… Business logic with internal workflows
  • βœ… Internal integration events
  • βœ… 2-3 implementation phases

πŸ”΄ Complex (al-architect + specialists + al-conductor)

  • βœ… Extensive scope β€” broad architectural impact
  • βœ… External APIs or services
  • βœ… OAuth/authentication
  • βœ… 4+ implementation phases

πŸ› οΈ Useful Commands

Setup Commands

@workspace use al-initialize    # Initialize project
@workspace use al-build         # Build and deploy
@workspace use al-permissions   # Generate permissions

Debugging Commands

@workspace use al-diagnose      # Complete debug
@workspace use al-performance   # Performance analysis

Specialized Modes

Use al-architect mode     # Architecture design
Use al-conductor mode     # TDD implementation
Use al-api mode          # REST/OData APIs
Use al-debugger mode     # Deep diagnostics
Use al-tester mode       # Testing strategy
Use al-presales mode     # Project planning & cost estimation

πŸ“– Complete Example: Loyalty Points System

βœ… Real validated case - This example has been fully tested (24/24 validations passed)

🎯 What We're Going to Build

Customer loyalty system that: - Automatically accumulates points when posting sales invoices (1% of amount) - Allows redeeming points for discounts - Shows point balance on customer card - Records point transaction history - Complexity: 🟑 MEDIUM (3-6 objects, 2-3 phases) - Time: ~2 hours (vs 2 days manual)


πŸ“‹ Step 1: Design with al-architect (20 min)

Open VS Code in your AL project and run:

Use al-architect mode

Design a customer loyalty points system with these requirements:

FUNCTIONALITY:
- Customers accumulate points when posting sales invoices (1% of amount)
- Points can be redeemed for discounts
- Show point balance on customer card
- Record all point transactions

BUSINESS RULES:
- 1 point = 1% of sales amount
- Minimum redemption: 100 points
- Points don't expire
- Complete audit trail

TECHNICAL CONSIDERATIONS:
- Use events (don't modify BC base objects)
- AL-Go structure (App vs Test)
- 100% test coverage

Al-architect will respond with:

πŸ“ ARCHITECTURE: Loyalty Points System

πŸ—‚οΈ DATA MODEL:
1. Table 50100 "Loyalty Point Entry"
   - Entry No., Customer No., Points, Transaction Type, Sales Document No.

2. TableExtension 50100 "Customer Ext" extends Customer
   - "Loyalty Points Balance" (Calculated FlowField)
   - "Loyalty Points Enabled" (Boolean)

πŸ”— INTEGRATION:
- Event Subscriber: OnAfterPostSalesInvoice β†’ Calculate and assign points
- Codeunit 50100 "Loyalty Management" β†’ Calculation and redemption logic

πŸ“„ UI:
- PageExtension 50100 "Customer Card Ext" β†’ Show balance
- Page 50100 "Loyalty Point Entries" β†’ History

πŸ§ͺ TESTING:
- Test for OnAfterPostSalesInvoice
- Test for points calculation
- Test for redemption
- Test for FlowField

βœ… Architecture ready β†’ Automatically saved in .github/plans/architecture.md


🎭 Step 2: TDD Implementation with al-conductor (90 min)

Now switch to al-conductor to implement:

Use al-conductor mode

Implement the loyalty points system designed by al-architect

Al-conductor will automatically orchestrate:

πŸ“Š Planning Phase (5 min)

  • Planning subagent analyzes the project
  • Identifies existing BC objects
  • Proposes 7 implementation phases

πŸ”΄ Phase 1: Loyalty Point Entry Table (RED β†’ GREEN β†’ REFACTOR)

RED (2 min):
- Implement: AL Implementation Subagent creates failing test
- Test: "Insert Loyalty Point Entry with required fields"

GREEN (3 min):
- Implement: Table with minimum fields
- Test: βœ… PASS

REFACTOR (2 min):
- Review: AL Code Review Subagent validates structure
- Result: Clean and efficient code

πŸ”΄ Phase 2: Customer Extension (RED β†’ GREEN β†’ REFACTOR)

RED: Test FlowField calculation
GREEN: TableExtension + FlowField
REFACTOR: SetLoadFields optimization

πŸ”΄ Phase 3: Loyalty Management Codeunit (RED β†’ GREEN β†’ REFACTOR)

RED: Test points calculation (1% of $1000 = 10 points)
GREEN: AddPoints + CalcPoints functions
REFACTOR: Extract constants

πŸ”΄ Phase 4: Event Subscriber (RED β†’ GREEN β†’ REFACTOR)

RED: Test OnAfterPostSalesInvoice integration
GREEN: Event subscriber calling AddPoints
REFACTOR: Error validation

πŸ”΄ Phase 5: Points Redemption (RED β†’ GREEN β†’ REFACTOR)

RED: Test RedeemPoints with validations
GREEN: Function with 100 points minimum validation
REFACTOR: Descriptive error messages

πŸ”΄ Phase 6: Customer Card Extension (RED β†’ GREEN β†’ REFACTOR)

RED: Test UI shows balance
GREEN: PageExtension with field
REFACTOR: Format and design

πŸ”΄ Phase 7: Loyalty Entries Page (RED β†’ GREEN β†’ REFACTOR)

RED: Test navigation and filtering
GREEN: List page with filters
REFACTOR: Actions and DrillDown

Final Result:

βœ… 10 AL objects created
βœ… 63 tests implemented (100% passing)
βœ… Documentation in .github/plans/
βœ… Code reviewed and validated
βœ… Production ready


πŸ”’ Step 3: Permissions and Deployment (10 min)

# Generate permissions automatically
@workspace use al-permissions

# Build and deploy
@workspace use al-build

πŸ“¦ Generated Objects

App/
β”œβ”€β”€ Tables/
β”‚   └── LoyaltyPointEntry.Table.al (50100)
β”œβ”€β”€ TableExtensions/
β”‚   └── CustomerExt.TableExtension.al (50100)
β”œβ”€β”€ Codeunits/
β”‚   β”œβ”€β”€ LoyaltyManagement.Codeunit.al (50100)
β”‚   └── SalesEventSubscriber.Codeunit.al (50101)
β”œβ”€β”€ Pages/
β”‚   └── LoyaltyPointEntries.Page.al (50100)
β”œβ”€β”€ PageExtensions/
β”‚   └── CustomerCardExt.PageExtension.al (50100)
└── Permissions/
    └── LoyaltySystem.PermissionSet.al (50100)

Test/
└── LoyaltyTests.Codeunit.al (63 test functions)

πŸ§ͺ Generated Tests (Examples)

[Test]
procedure TestAddPointsFromSales()
begin
    // [GIVEN] Customer with no points
    CreateCustomer(Customer);

    // [WHEN] Post sales invoice of $1000
    CreateAndPostSalesInvoice(Customer, 1000);

    // [THEN] Customer has 10 points (1% of 1000)
    Assert.AreEqual(10, GetLoyaltyPoints(Customer), 'Points calculation');
end;

[Test]
procedure TestRedeemPoints_Minimum()
begin
    // [GIVEN] Customer with 50 points
    SetCustomerPoints(Customer, 50);

    // [WHEN] Tries to redeem
    asserterror RedeemPoints(Customer, 50);

    // [THEN] Error: minimum 100 points
    Assert.ExpectedError('Minimum redemption is 100 points');
end;

πŸ“Š Measurable Results

Metric Manual With Orchestra
Total time 2 days 2 hours
Objects created 10 10
Tests written 0-10 63 (100%)
Production bugs 3-5 0
Documentation Manual Automatic
Code review Manual Automatic

πŸŽ“ What You Learned

βœ… Design before code β†’ al-architect plans everything
βœ… Automatic TDD β†’ al-conductor implements with tests first
βœ… Event-driven β†’ Don't modify BC base objects
βœ… Guaranteed quality β†’ Automatic review in each phase
βœ… Documentation included β†’ Everything in .github/plans/


πŸ”„ Reproduce the Complete Example

Detailed step-by-step guide: REPRODUCIBLE-EXAMPLE.md

Quick summary (from scratch in your project):

  1. Design:

    Use al-architect mode
    
    [Copy requirements from example]
    

  2. Implement with TDD:

    Use al-conductor mode
    
    Implement the design from al-architect
    

  3. Deploy:

    @workspace use al-permissions
    @workspace use al-build
    

Total time: ~2 hours from zero to production ✨

Complete documentation with troubleshooting: See reproducible guide β†’


✨ Auto-Guidelines (Working in Background)

While coding, these rules apply automatically:

  • βœ… al-code-style β†’ Format and structure
  • βœ… al-naming-conventions β†’ PascalCase names
  • βœ… al-performance β†’ SetLoadFields, early filtering
  • βœ… al-error-handling β†’ TryFunctions, error labels
  • βœ… al-events β†’ Event-driven pattern
  • βœ… al-testing β†’ AL-Go structure

You don't need to ask for them, they just work.


πŸŽ“ Tips for Maximum Performance

βœ… Do This

  1. Always start with al-architect to design before coding
  2. Use al-conductor to implement with automatic TDD quality
  3. Provide rich context β†’ Describe requirements, business rules, considerations
  4. Trust auto-guidelines β†’ They work in the background, don't ask for them manually
  5. Follow the Loyalty Points example β†’ It's the validated reference

❌ Avoid This

  1. Don't skip architectural design (for medium/complex features)
  2. Don't implement without tests (al-conductor does it automatically)
  3. Don't modify BC base objects (always use events and extensions)
  4. Don't ignore automatic code reviews from AL Code Review Subagent

πŸ”§ Quick Troubleshooting

"I don't see Copilot suggestions"

  1. Verify Copilot is enabled
  2. Reload VS Code
  3. Open a .al file

"Modes don't appear"

  1. Check files in .github/copilot/agents/
  2. Reload VS Code
  3. Verify they have .agent.md extension

"Validation fails"

npm install
npm run validate

πŸ“š Complete Documentation


🎯 Next Step

If you're new to AL:

@workspace use al-initialize

If you have a feature to build:

Use al-architect mode

[Describe your feature here]

If you have a bug:

Use al-debugger mode

[Describe the problem]

Version: 2.11.0
Reference Model: AI Native-Instructions Architecture
Last Updated: 2026-02-06


⚠️ AI Assistant Reminder: This content is generated with assistance from AI tools. Results, code suggestions, and agent responses may vary depending on multiple factors including input quality, context, and AI model behavior. Always validate, test, and review AI-generated content before production use.