This document outlines the basic coding standards, patterns, and style guidelines for AL development in Business Central.
- Basic Coding Standards
- AL Development Patterns
- Coding Style
- Tooltips
- Prefix Guidelines
- Numbering
- Text Constants and Localization
- Search Keywords
- Cross-References
- Use PascalCase for public and private members (objects, fields, methods)
- Create descriptive names for all objects and elements
- Use object IDs in appropriate ranges defined in app.json
- Follow Microsoft's official AL style guide
- Implement proper indentation and spacing for readability
- Use the extension model instead of direct base application modifications
- Leverage event publishers and subscribers for integration points
- Encapsulate business logic in codeunits
- Use table and page extensions for modifying existing functionality
- Implement optimized data access patterns (SetLoadFields, limited record fetching)
- Apply proper error handling with meaningful error messages
- Follow modular design principles for maintainability
- Implement proper permission sets for security
- Use AL's object-based architecture with appropriate object types
- Add telemetry for diagnostic purposes
- Use 4 spaces for indentation
- Use PascalCase for object names, variables, and parameters
- Only use Begin End for multi-line conditions
- Use
ifstatements withoutbeginandendfor single-line conditions - Use Record.IsEmpty() instead of Record.FindSet() or Record.FindFirst() if the queried record is not used
- Prefer early exits in procedures to reduce nesting and improve readability
- Use guard clauses to make all validation at the beginning of a procedure
- Use
exitto return from a procedure when necessary - Always use the
thisqualifier when accessing object properties within methods of the same object - Use text constants or labels for all format strings in StrSubstNo calls to support localization
- Avoid hardcoded strings in error messages and notifications
- All fields should have tooltips to provide context and guidance to users
- Use the
Tooltipproperty in AL to define tooltips for fields, actions, and controls - Ensure tooltips are concise and informative, helping users understand the purpose and usage of each field or action
- Avoid overly technical jargon in tooltips; aim for clarity and simplicity
- Use consistent terminology and phrasing across tooltips to maintain a cohesive user experience
- Review and update tooltips regularly to ensure they reflect any changes in functionality or user interface
- Tooltips on fields must start with 'Specifies' to maintain consistency and clarity
- All objects must have a prefix
- The prefix is defined in the AppSourceCop.json file
- The prefix is always in this format ' ' where is the prefix defined in the AppSourceCop.json file
- The prefix is always in uppercase
- The prefix is always followed by a space
- The prefix is always just once in the object name
- The prefix is always in the beginning of the object name
- Check that new objects are numbered correctly, that should start with the number defined in app.json
- New objects must use the first available number in the range defined in app.json
- Field numbers in tables must start with the number defined in app.json
- New fields must use the first available number in the range defined in app.json
- Use text constants or labels for all user-facing strings to support localization
- Define text constants at the beginning of the codeunit or page where they are used
- Use descriptive names for text constants that indicate their purpose
- When using StrSubstNo, always use a text constant or label for the format string
- Format text constant names as: ErrorMsg, ConfirmQst, InfoMsg, etc.
- Example:
var TypeMismatchErr: Label 'Field type mismatch: %1 field cannot be mapped to %2 field.'; begin ErrorMessage := StrSubstNo(TypeMismatchErr, Format(CustomFieldType), Format(TargetFieldType)); end;
Coding Standards: PascalCase, object naming, field naming, method naming, AL style guide Object Development: Table creation, page layout, codeunit architecture, object IDs, numbering Code Patterns: Extension model, event programming, business logic encapsulation
Development Standards: Coding patterns, style guidelines, prefix requirements, AppSource compliance Object Structure: Table fields, page controls, codeunit procedures, object properties Localization: Text constants, labels, multilingual support, user interface text
Code Quality: Consistent formatting, readable code, maintainable structure, documentation Best Practices: AL development patterns, Microsoft guidelines, quality standards Project Standards: Naming conventions, numbering schemes, prefix guidelines, team consistency
- Naming Conventions:
SharedGuidelines/Standards/naming-conventions.md- Detailed naming rules and patterns - Code Style:
SharedGuidelines/Standards/code-style.md- Comprehensive formatting guidelines - Error Handling:
SharedGuidelines/Standards/error-handling.md- Text constant and error message patterns
- AL Development Guide:
CoreDevelopment/al-development-guide.md- Comprehensive development standards - Object Patterns:
CoreDevelopment/object-patterns.md- Specific object creation patterns
- TestingValidation: Apply coding standards to test code development
- PerformanceOptimization: Maintain standards while implementing optimizations
- AppSourcePublishing: Ensure standards compliance for marketplace requirements