GitHub Copilot Chat is a conversational AI assistant integrated into Visual Studio Code that allows you to ask questions, get explanations, and receive guidance through natural language interaction.
Developer: GitHub (Microsoft)
Type: Conversational AI Agent
Primary Use: Interactive code assistance, explanations, and debugging
Integration: Native VS Code extension
GitHub Copilot Chat provides an interactive AI assistant that:
Example Interaction:
You: Explain how this procedure validates customer credit limits
Chat: This procedure validates customer credit limits by:
1. Retrieving the customer record
2. Calculating current outstanding amount
3. Comparing against credit limit
4. Raising an error if exceeded
The validation ensures customers cannot exceed their credit limits
before creating new sales orders...
Code Explanation:
Interactive Learning:
Debugging Assistance:
Code Generation:
Open Chat:
Ctrl+Shift+I
(Windows/Linux)Cmd+Shift+I
(Mac)Chat Interface:
┌─────────────────────────────┐
│ GitHub Copilot Chat │
├─────────────────────────────┤
│ Your conversation history │
│ │
│ You: How do I... │
│ Copilot: You can... │
│ │
├─────────────────────────────┤
│ Type your question... [>]│
└─────────────────────────────┘
Open Inline:
Ctrl+I
in editorUse Cases:
Quick access to common tasks:
Command | Purpose | Example |
---|---|---|
/explain | Explain selected code | /explain this validation logic |
/fix | Suggest fixes | /fix the error in this procedure |
/tests | Generate tests | /tests for this codeunit |
/help | Show commands | /help |
/clear | Clear chat | /clear |
Learning & Understanding:
Debugging Help:
Code Exploration:
Documentation:
Generated Code:
Complex Business Logic:
Performance Advice:
You:
Explain this procedure and when I should use it
[Select and paste this code]:
procedure CheckCreditLimit(var SalesHeader: Record "Sales Header")
var
Customer: Record Customer;
OutstandingAmount: Decimal;
begin
Customer.Get(SalesHeader."Sell-to Customer No.");
Customer.CalcFields("Balance (LCY)");
OutstandingAmount := Customer."Balance (LCY)" + SalesHeader."Amount Including VAT";
if OutstandingAmount > Customer."Credit Limit (LCY)" then
Error('Customer %1 would exceed credit limit. Outstanding: %2, Limit: %3',
Customer."No.", OutstandingAmount, Customer."Credit Limit (LCY)");
end;
Chat Explains:
This procedure validates customer credit limits before allowing sales orders:
Purpose:
- Prevents customers from exceeding their credit limits
- Calculates total outstanding amount (existing balance + new order)
- Raises an error if limit would be exceeded
When to use:
- Before posting sales orders
- In OnValidate triggers for sales headers
- As part of order validation workflow
Key points:
- Uses CalcFields to get current customer balance
- Adds new order amount to existing balance
- Compares total against credit limit
- Provides clear error message with details
Best practice considerations:
- Consider making error message translatable
- Might want to allow override with permission
- Could log credit limit violations for reporting
You:
Create a codeunit that processes sales orders in batch.
Requirements:
- Accept list of sales order numbers
- Validate each order (check credit, inventory)
- Post valid orders
- Collect and return errors for failed orders
- Log to telemetry
- Show progress dialog
Use proper error handling and AL best practices.
Chat Generates:
codeunit 50100 "Batch Sales Order Processor"
{
/// <summary>
/// Processes multiple sales orders in batch with validation and error handling
/// </summary>
procedure ProcessOrders(OrderNumbers: List of [Code[20]]): List of [Text]
var
SalesHeader: Record "Sales Header";
Errors: List of [Text];
Dialog: Dialog;
Counter: Integer;
TotalCount: Integer;
begin
TotalCount := OrderNumbers.Count;
Dialog.Open('Processing orders...\Order #1######### of #2#########');
foreach OrderNo in OrderNumbers do begin
Counter += 1;
Dialog.Update(1, Counter);
Dialog.Update(2, TotalCount);
if not ProcessSingleOrder(OrderNo, Errors) then
LogProcessingError(OrderNo, Errors);
end;
Dialog.Close();
LogBatchCompletion(TotalCount, Counter - Errors.Count, Errors.Count);
exit(Errors);
end;
local procedure ProcessSingleOrder(OrderNo: Code[20]; var Errors: List of [Text]): Boolean
var
SalesHeader: Record "Sales Header";
SalesPost: Codeunit "Sales-Post";
begin
if not SalesHeader.Get(SalesHeader."Document Type"::Order, OrderNo) then begin
Errors.Add(StrSubstNo('Order %1 not found', OrderNo));
exit(false);
end;
if not ValidateOrder(SalesHeader, Errors) then
exit(false);
if not SalesPost.Run(SalesHeader) then begin
Errors.Add(StrSubstNo('Order %1: %2', OrderNo, GetLastErrorText()));
exit(false);
end;
exit(true);
end;
// Additional helper procedures...
end;
You:
I'm getting error "The field Customer No. must have a value"
when trying to post a sales order. Here's my code:
[Paste problematic code]
What's wrong?
Chat Analyzes:
The error occurs because the Customer No. field is empty when posting.
Looking at your code, the issue is on line 15:
SalesHeader."Sell-to Customer No." := '';
This explicitly sets the customer number to empty before posting.
Likely causes:
1. Customer lookup/validation failed earlier
2. Field being cleared unintentionally
3. Missing validation before assignment
Recommended fixes:
1. Remove the line setting it to empty
2. Add validation:
if Customer.Get(CustomerNo) then
SalesHeader.Validate("Sell-to Customer No.", CustomerNo)
else
Error('Customer %1 does not exist', CustomerNo);
3. Add defensive check before posting:
if SalesHeader."Sell-to Customer No." = '' then
Error('Customer must be specified before posting');
Would you like me to show the corrected version of your code?
You:
What's the standard AL pattern for implementing a document posting routine?
Chat Explains:
Standard AL document posting routines follow this pattern:
1. Structure:
- Main posting codeunit
- Optional posting preview codeunit
- Optional batch posting codeunit
2. Main Posting Codeunit Pattern:
codeunit 50100 "Document-Post"
{
TableNo = "Your Document Header";
trigger OnRun()
begin
PostDocument(Rec);
end;
procedure PostDocument(var DocHeader: Record "Your Document Header")
var
DocLine: Record "Your Document Line";
begin
// 1. Pre-posting checks
CheckDocumentIsReadyToPost(DocHeader);
// 2. Run events (OnBeforePost)
OnBeforePostDocument(DocHeader);
// 3. Lock tables
DocHeader.LockTable();
// 4. Post with transaction
PostDocumentLines(DocHeader);
FinalizePosting(DocHeader);
// 5. Run events (OnAfterPost)
OnAfterPostDocument(DocHeader);
end;
// Additional procedures...
// Events for extensibility
[IntegrationEvent(false, false)]
local procedure OnBeforePostDocument(var DocHeader: Record "Your Document Header")
begin
end;
}
Key principles:
- Use transactions (implicit in OnRun trigger)
- Lock records being modified
- Provide integration events
- Validate before posting
- Handle errors gracefully
- Use Codeunit.Run for error handling
Would you like examples of specific parts?
Copilot Chat:
Copilot (Inline):
Use Together: Inline for coding, Chat for understanding
Copilot Chat:
Claude:
Use Cases: Chat for daily work, Claude for deep analysis
Copilot Chat:
Cursor:
Use Cases: Chat for standard workflow, Cursor for advanced needs
Be Specific:
❌ "Explain this"
✅ "Explain how this procedure handles inventory updates
and why it uses a transaction"
Provide Context:
❌ "How do I validate?"
✅ "How do I validate customer credit limits in AL before
posting a sales order? Show me the BC standard pattern."
Break Down Complex Questions:
Instead of:
"Build complete order management system"
Try:
1. "Show me pattern for order validation"
2. "Now add posting logic"
3. "Add error handling"
4. "Add telemetry"
Review Code:
Learn from Explanations:
Iterate:
See GitHub Copilot Chat Tool Page for detailed setup.
Quick Start:
Ctrl+Shift+I
)Provide Context:
Included with GitHub Copilot:
No separate charge - comes with Copilot subscription.
Daily Development:
Learning:
Code Review:
Use With:
Workflow:
Next Steps:
Questions? Join GitHub Discussions
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.