Prompt Review Business Central AL code

 Top 10 reusable prompts — Review Business Central AL code as a senior developer (with suggested fixes + code snippets)

Copy any prompt, paste your AL code where indicated, and send to the model. Each prompt follows the structure you asked: Role Assignment + Clear Task/Goal + Context/Constraints + Desired Output Format.

  1. Performance review — reduce DB calls
    Role Assignment: Act as a senior Business Central AL performance engineer.
    Task/Goal: Review the pasted AL code and identify places that cause excessive database reads/writes; propose changes to minimize I/O.
    Context/Constraints: Code runs on Sales Order processing for large datasets (100k+ lines). Avoid changing business logic; focus on batching, FindSet/Update, use of Temporary tables, and FlowFields.
    Desired Output Format: List of detected performance issues (numbered) + short explanation each + a corrected code snippet showing the hottest function refactored (before/after) and a brief benchmark plan to validate improvement.
    Placeholder: [PASTE AL CODE HERE]


  1. Eventing & extensibility review
    Role Assignment: Act as a senior AL architect specializing in events and extensibility.
    Task/Goal: Review the pasted code for hard-coded hooks and suggest how to expose IntegrationEvents/BusinessEvents to make it extensible without breaking changes.
    Context/Constraints: Target solution must support extensibility by partners and follow MS naming conventions and var/const patterns. Keep backward compatibility in mind.
    Desired Output Format: Identified rigidity points + recommended event publishers/subscribers with full AL event code snippets (publisher + example subscriber) and guidance where to place them (object & trigger).
    Placeholder: [PASTE AL CODE HERE]


  1. Error handling & user messaging
    Role Assignment: Act as a senior AL reliability engineer.
    Task/Goal: Review error handling in the pasted code and propose a robust TRY-CATCH strategy, consistent error messages, and error logging.
    Context/Constraints: Use GetLastErrorText(), store errors in a “Log Entries” table, and avoid exposing raw system exceptions to end users. Support multi-language captions.
    Desired Output Format: Short list of problems found + a standardized TRY-CATCH wrapper code snippet + example of how to log and present a friendly message to the user (before/after).
    Placeholder: [PASTE AL CODE HERE]


  1. Security & permission review
    Role Assignment: Act as a senior BC security/permissions specialist.
    Task/Goal: Review code for permission/security issues (sensitive data, direct SQL, misuse of CurrPage, functions callable by users) and recommend PermissionSet/Object-level controls.
    Context/Constraints: Target Business Central best practices; avoid runtime elevation; prefer PermissionSet definitions over role assumptions.
    Desired Output Format: List of security risks + recommended PermissionSet XML/AL snippet(s) + code changes to enforce checks (e.g., CurrUserHasPermission) with an example enforcement snippet.
    Placeholder: [PASTE AL CODE HERE]


  1. Code quality & maintainability review
    Role Assignment: Act as a senior AL code-quality lead.
    Task/Goal: Review pasted code for naming, single-responsibility, duplication, and adherence to AL style rules; produce refactoring suggestions.
    Context/Constraints: Keep public APIs stable; prefer small, testable procedures; follow camelCase for locals and PascalCase for procedures.
    Desired Output Format: Priority-ranked list of refactors + one example refactor transforming a large procedure into 2–3 small procedures with full before/after AL code snippets.
    Placeholder: [PASTE AL CODE HERE]


  1. Unit testing & testability review
    Role Assignment: Act as a senior AL testing engineer.
    Task/Goal: Evaluate the pasted code for testability; suggest unit tests and mocks; provide test codeunits.
    Context/Constraints: Use the AL Test Framework (TestToolKit patterns), isolate tests per company, avoid external dependencies in tests.
    Desired Output Format: Problems preventing testability + 2–3 unit test codeunits (Arrange/Act/Assert) that target key logic + suggestions for required refactors to enable tests.
    Placeholder: [PASTE AL CODE HERE]


  1. Concurrency & Job Queue safety review
    Role Assignment: Act as a senior AL concurrency/operations engineer.
    Task/Goal: Review code for concurrency issues (deadlocks, race conditions) and propose Job Queue or locking patterns.
    Context/Constraints: Code runs in multi-user environment; some functions are executed by Job Queue concurrently; preserve idempotency.
    Desired Output Format: Detected concurrency risks + recommended locking or optimistic concurrency changes + example AL pattern using Record.LockTable / Job Queue-safe code snippet.
    Placeholder: [PASTE AL CODE HERE]


  1. Integration / API reliability review
    Role Assignment: Act as a senior AL integration architect.
    Task/Goal: Review REST/HttpClient or JSON handling in the pasted code. Suggest improvements for retries, timeouts, JSON parsing, and secure credential handling.
    Context/Constraints: Use HttpClient, JsonObject, secure storage for keys (Azure Key Vault or BC Credential Management), implement exponential backoff for retries.
    Desired Output Format: Identified fragilities + hardened HttpClient wrapper code snippet showing retry/backoff + secure key retrieval example + parsing error handling snippet.
    Placeholder: [PASTE AL CODE HERE]


  1. Upgrade & data migration review
    Role Assignment: Act as a senior AL upgrade/migration engineer.
    Task/Goal: Review the pasted upgrade/codeunit or migration logic; propose an OnUpgradePerCompany plan that is idempotent and safe for large datasets.
    Context/Constraints: Support rollback-friendly steps, progress logging, batch processing for millions of rows, and compatibility with older versions.
    Desired Output Format: Step-by-step upgrade plan + AL upgrade codeunit sample performing safe batched migrations (with checkpoints) and logging.
    Placeholder: [PASTE AL CODE HERE]


  1. UI/UX & page performance review
    Role Assignment: Act as a senior AL UI/UX engineer.
    Task/Goal: Review Page/PageExtension code for usability and performance (too many FlowFields, heavy OnOpenPage logic). Provide improvements.
    Context/Constraints: Keep ApplicationArea and ToolTips; minimize synchronous long-running logic on page open; use FactBoxes or background jobs if needed.
    Desired Output Format: Usability issues (bulleted) + revised Page/PageExtension code snippet replacing heavy OnOpenPage with an async JobQueue call or optimizing FlowFields (before/after).
    Placeholder: [PASTE AL CODE HERE]

50 reusable prompts — Review, Universal Code Initiative (UCI), Best Practices & AI-optimized coding rules for Business Central AL


Prompt IDScenarioRole and Prompt Example (Hinglish/English)
1Naming Conventions ReviewAct as Senior BC AL Developer. Review this AL code for adherence to Universal Code Initiative (UCI) naming conventions. Suggest improvements and a corrected code snippet.
2Code Readability EnhancementAs Senior Developer, review this AL code focusing on readability and maintainability. Provide refactored code with comments.
3Performance Best PracticesActing as AL Performance Expert, analyze code for expensive loops and DB calls. Suggest best practice optimizations with code snippet improvements.
4Data Classification ComplianceAs Security Expert, check the code for proper data classification usage per Universal Code Initiative. Suggest fixes with examples.
5Error Handling & LoggingReview AL procedure for robust error handling aligned with best practices. Suggest enhanced try/catch and logging implementation with code example.
6Modular Code ReviewAnalyze AL code for modularity and single responsibility principle compliance. Suggest refactorings and provide example modular code parts.
7Event Handling EfficiencyReview event subscriber implementation for efficient event handling and avoidance of common pitfalls. Suggest refined code snippet.
8UI/UX Consistency CheckReview page extensions and UI modifications for consistency with Business Central UX guidelines. Provide improved AL UI code.
9Security & Permission ChecksValidate code for adequate permission and security checks before sensitive operations. Provide refactored secure code snippet.
10Unit Testability AssessmentEvaluate code structure for ease of unit testing. Suggest improvements and create sample unit test and refactored code.
11Inline Documentation QualityReview inline comments and XML documentation. Suggest improvements and show enhanced documented code.
12API Integration ConformanceAnalyze AL code integrating with external APIs for adherence to best practices and error handling. Propose improved API consuming code.
13Custom Error MessagesCheck clarity and user friendliness of error messages in AL code. Propose improved messages with examples.
14Localization SupportReview code for proper use of localization and labels. Provide improved localization-ready AL code snippet.
15Use of Constants and EnumerationsReview magic numbers and strings replaced appropriately with constants/enums. Suggest improvements and code examples.
16Deprecation and CompatibilityEvaluate code for deprecated calls and ensure compatibility with the latest BC versions. Suggest compliant code changes.
17Extension Upgrade ReadinessAssess code readiness for smooth upgrades and migration scenarios. Include improved upgrade-safe code snippets.
18Code Duplication EliminationIdentify duplicated code blocks. Suggest abstractions or functions to eliminate duplication with examples.
19Secure Data HandlingCheck encryption and secure handling of sensitive data fields. Provide improved secure handling code.
20Query OptimizationReview database queries and filter usage for optimization. Suggest better AL query syntax or code restructuring.
21Proper Use of Try FunctionsCheck use of Try functions for non-intrusive error handling. Suggest improvements and code examples.
22Meaningful Variable NamesReview for meaningful variable names. Suggest renaming to enhance clarity and provide before-after code snippet.
23Code Formatting StandardsCheck for consistent code formatting (indentation, spacing). Provide reformatted code snippet.
24User Permission SetsReview creation and use of user permission sets. Suggest best practice AL code for permission management.
25Batch Job SafetyEvaluate scheduling and batch jobs code for robustness. Propose safer code approaches with examples.
26Minimal Data ExposureCheck for exposure of only necessary data, avoiding oversharing. Suggest code to limit data exposure.
27Use of Code AnalyzersAssess the use of AL code analyzers. Suggest fixes for analyzer warnings and improved code style.
28Table Relation IntegrityReview table relation declaration for consistency and performance. Suggest improved relationship definitions.
29Deprecated Function ReplacementIdentify deprecated functions. Suggest modern equivalents with code samples.
30Meaningful Error LoggingReview logging strategy for error traceability. Improve log entries and provide better logging code.
31Refactor Long FunctionsFind overly long functions. Propose splitting into smaller, reusable functions with examples.
32Consistent Use of Page ControlsCheck page control usage for consistency and maintainability. Suggest code improvements.
33Proper Use of Temporary TablesReview temporary table usage in processing logic. Suggest best practices and improved code.
34Comprehensive Test CoverageEvaluate the codebase for unit test coverage. Suggest additional test cases and example tests.
35Proper Use of Recurring JobsReview scheduling of recurring jobs for business logic. Suggest improvements for reliability.
36Efficient Use of DataItem FiltersReview use of filters in reports. Suggest improvements for performance and clarity.
37Clear Separation of ConcernsAssess logical separation of UI, business logic, and data access layers. Suggest refactoring suggestions.
38Use of New AL Language FeaturesReview use of latest AL language features for efficiency and clarity. Suggest code upgrades.
39Localization-Friendly UICheck UI code for localization readiness. Suggest improvements for internationalization.
40Consistent Use of Data TypesVerify consistent application of appropriate data types. Suggest corrections where needed.
41Safe Codeunit InstancingReview codeunit usage for safe and optimal instancing practices. Provide improved usage examples.
42Minimize Cross-Table AccessIdentify and optimize excessive cross-table access patterns. Suggest improved data access patterns.
43Clear Function ResponsibilityReview functions for single responsibility. Suggest improvements with example function splits.
44Use of Interface and AbstractionCheck for use of interfaces and abstraction layers. Suggest adding these where appropriate.
45Security Roles-Related Code ReviewEvaluate code related to security roles and permissions. Suggest tightened security implementations.
46Dependency Injection UsageCheck for DI usage where applicable. Suggest code improvements to use dependency injection.
47Error Context ClarityReview error messages and logging for sufficient context. Provide clearer error handling code.
48Cleanup Resources ProperlyCheck code for proper cleanup of resources (e.g., restore cursor, reset temp tables). Provide improved snippets.
49Use of Modern Debugging PracticesSuggest use of modern AL debugging practices. Suggest code additions for logging and telemetry.
50Documentation CompletenessReview code comments and external documentation. Suggest adding missing documentation blocks with examples.

General code quality & architecture

  1. Role Assignment: Act as a senior Business Central AL architect and UCI reviewer.
    Task/Goal: Perform a full-code review of the pasted AL file for adherence to Universal Code Initiative (UCI) and AL best practices.
    Context/Constraints: Keep public API stable, don't alter business logic, mark breaking changes clearly.
    Desired Output Format: Numbered list of issues (severity), remediation suggestions, 2–3 before/after snippets for the most critical fixes, and a short risk/impact note.

  2. Role Assignment: Act as a senior AL refactoring expert.
    Task/Goal: Identify long procedures (>200 lines) and refactor suggestions to follow single-responsibility and modular design.
    Context/Constraints: Maintain original behavior; preserve variable names used externally.
    Desired Output Format: List of candidate procedures + concrete refactor split with before/after code snippets and suggested new procedure names.

  3. Role Assignment: Act as a SOLID and UCI specialist.
    Task/Goal: Review object for violations of SOLID principles and propose concrete code-level changes.
    Context/Constraints: Show how to separate concerns without changing external signatures.
    Desired Output Format: For each violation: explanation, proposed pattern (interface/codeunit split), and example AL code demonstrating the fix.

  4. Role Assignment: Act as a naming-standards reviewer.
    Task/Goal: Check naming for tables, variables, procedures, and constants against UCI naming rules and Microsoft AL conventions.
    Context/Constraints: Suggest consistent camelCase for locals, PascalCase for procedures, prefixes for globals.
    Desired Output Format: Table of problematic identifiers + suggested replacements + automated regex rules to find occurrences.

  5. Role Assignment: Act as a code-linter rules author (AL).
    Task/Goal: Generate a set of UCI/AI-friendly linting rules for AL (e.g., max procedure length, no magic numbers, explicit var/const).
    Context/Constraints: Rules must be actionable and automatable by a pre-commit tool.
    Desired Output Format: Enumerated lint rules + example violation and corrected snippet for each.


Performance & database I/O

  1. Role Assignment: Act as an AL performance engineer.
    Task/Goal: Find excessive DB reads/writes in pasted code and propose batching/temp table usage.
    Context/Constraints: Target large datasets (100k+ rows). Avoid changing final results.
    Desired Output Format: Hotspots list + optimized code snippet (FindSet/Update batching or use of Temporary table) + explanation of complexity reduction.

  2. Role Assignment: Act as an index and key advisor.
    Task/Goal: Review table usage and suggest key/index changes or FlowField alternatives to improve read performance.
    Context/Constraints: Include potential impact on writes and Explain how to update keys safely.
    Desired Output Format: Table of suggested key changes + AL table code snippet for key change + migration consideration notes.

  3. Role Assignment: Act as an AL caching expert.
    Task/Goal: Propose a caching strategy to reduce repetitive lookups in the pasted code.
    Context/Constraints: Use single-instance codeunit or in-memory temporary records; ensure cache invalidation.
    Desired Output Format: Cache implementation code snippet + invalidation rules and example usage.

  4. Role Assignment: Act as a FlowField optimization specialist.
    Task/Goal: Identify problematic FlowFields used in UI triggers and recommend precomputed alternatives or job-queue calculation.
    Context/Constraints: Minimize synchronous computation on page load.
    Desired Output Format: Example refactor from FlowField → stored aggregate + Job Queue code snippet to recalc.

  5. Role Assignment: Act as a memory & tempblob reviewer.
    Task/Goal: Audit code for heavy memory/tempblob usage and propose streaming or chunked processing alternatives.
    Context/Constraints: Target file imports and large JSON payloads.
    Desired Output Format: Problem summary + chunked processing AL snippet and recommended safe buffer sizes.


Events, extensibility & UCI patterns

  1. Role Assignment: Act as an event-design authority (UCI patterns).
    Task/Goal: Review the object for hard-coded extension points and propose IntegrationEvent/BusinessEvent publishers/subscribers to enable extensibility.
    Context/Constraints: Keep parameter VAR where appropriate; follow naming conventions OnBefore/OnAfter.
    Desired Output Format: Suggested event publishers + example publisher + example subscriber code.

  2. Role Assignment: Act as backward-compatibility reviewer.
    Task/Goal: Identify potential breaking changes and propose UCI-compatible extension points to avoid them.
    Context/Constraints: Provide migration path for existing consumers.
    Desired Output Format: List of breaking points + suggested non-breaking alternatives + sample event-based replacement snippet.

  3. Role Assignment: Act as an API contract guardian.
    Task/Goal: Verify exposed API pages/queries for stable field names and versioned contracts.
    Context/Constraints: Propose strategy for versioned API pages and deprecation headers.
    Desired Output Format: Versioning scheme + code snippet for API page v1 → v2 and deprecation notice.

  4. Role Assignment: Act as an UCI module interface designer.
    Task/Goal: Recommend modular boundaries and interfaces for the pasted extension (to make modules independently testable).
    Context/Constraints: Use AL interfaces and small codeunits.
    Desired Output Format: Proposed module map + interface AL code + sample implementation.

  5. Role Assignment: Act as an event conflict detection expert.
    Task/Goal: Detect situations where multiple subscribers may conflict and propose ordering or filter patterns.
    Context/Constraints: Preserve idempotency; avoid implicit side effects.
    Desired Output Format: Conflicting subscribers list + recommended subscriber filters/priorities + sample safe subscriber.


Error handling, logging & telemetry

  1. Role Assignment: Act as a reliability/UCI logging lead.
    Task/Goal: Review error handling and transform ad-hoc messages into standardized, localizable errors + structured telemetry.
    Context/Constraints: Use GetLastErrorText(), Session.LogMessage, and a custom Log table. Avoid exposing stack traces to users.
    Desired Output Format: Standard TRY/CATCH wrapper + logging codeunit snippet + sample log record schema.

  2. Role Assignment: Act as a telemetry optimization engineer.
    Task/Goal: Propose telemetry points to capture performance and business metrics in pasted code.
    Context/Constraints: Low overhead; GDPR-compliant (no PII).
    Desired Output Format: List of telemetry events + AL code to send Session.LogMessage + example event payload.

  3. Role Assignment: Act as an alerting & retry expert.
    Task/Goal: Add retry/backoff logic for external calls in the pasted code and alert rules for failures.
    Context/Constraints: Implement exponential backoff with max retries and logging.
    Desired Output Format: HttpClient wrapper code with retry/backoff + alerting log snippet.

  4. Role Assignment: Act as a localized message & UX reviewer.
    Task/Goal: Replace hard-coded English messages with resource captions and multi-language support.
    Context/Constraints: Provide ENU and one other language example.
    Desired Output Format: Example of Message/Err/Confirm replaced with Label and translations + AL resource snippet.

  5. Role Assignment: Act as an audit & compliance specialist.
    Task/Goal: Ensure actions are auditable (who/when/what) and add minimal audit logs for critical operations.
    Context/Constraints: Store minimal PII; fields must be DataClassification annotated.
    Desired Output Format: Audit table design + sample LogAction procedure + usage examples.


Security & permissions

  1. Role Assignment: Act as a BC security architect.
    Task/Goal: Review code for insecure patterns (hard-coded credentials, direct DB calls, elevation of privileges).
    Context/Constraints: Recommend secure storage and usage patterns.
    Desired Output Format: Risk list + secure alternative code snippets (Credential Management, Azure Key Vault example pseudo-code).

  2. Role Assignment: Act as a PermissionSet reviewer.
    Task/Goal: Generate minimal permission sets needed for new features in pasted code and highlight over-privileged operations.
    Context/Constraints: Follow least-privilege principle.
    Desired Output Format: PermissionSet AL object snippets + mapping of objects → required permissions.

  3. Role Assignment: Act as an input-sanitization expert.
    Task/Goal: Ensure external inputs (JSON, CSV, API payloads) are validated and sanitized before use.
    Context/Constraints: Provide defensive parsing patterns and schema checks.
    Desired Output Format: Validation helper code + JSON schema-like checks + example sanitization snippet.

  4. Role Assignment: Act as a secure integration specialist.
    Task/Goal: Review external API integration patterns in pasted code and enforce token handling/security best practices.
    Context/Constraints: Use secure storage for secrets, avoid logging tokens.
    Desired Output Format: Secure HttpClient usage snippet + token refresh and storage pattern.

  5. Role Assignment: Act as a data-classification & PII reviewer.
    Task/Goal: Identify PII fields and recommend DataClassification labels and access controls per UCI.
    Context/Constraints: Use Microsoft DataClassification categories.
    Desired Output Format: Annotated field list + AL snippet showing DataClassification attributes.


Testing, CI/CD & DevOps

  1. Role Assignment: Act as a unit-testing lead.
    Task/Goal: Propose unit tests for key functions in pasted code and provide test codeunits.
    Context/Constraints: Use AL Test Framework, isolate per company, and mock external dependencies.
    Desired Output Format: 2–3 AL test codeunits (Arrange/Act/Assert) + mock patterns.

  2. Role Assignment: Act as a testability refactorer.
    Task/Goal: Identify barriers to testability (static code, external calls inside logic) and refactor examples to enable mocking.
    Context/Constraints: Show before/after to allow unit tests without external resources.
    Desired Output Format: Refactor snippet + sample test consuming the refactored code.

  3. Role Assignment: Act as a CI/CD pipeline adviser for AL.
    Task/Goal: Provide a CI step checklist that enforces UCI rules (lint, unit tests, code coverage threshold, symbol validation).
    Context/Constraints: GitHub Actions / Azure DevOps friendly.
    Desired Output Format: YAML snippet outline + commands for checks.

  4. Role Assignment: Act as an automated release/versioning expert.
    Task/Goal: Propose a versioning scheme for app.json and pipeline automation to bump versions safely.
    Context/Constraints: Major.Minor.Patch with build metadata; preserve compatibility.
    Desired Output Format: PowerShell or YAML snippet to auto-increment version + guidelines.

  5. Role Assignment: Act as a build stability engineer.
    Task/Goal: Detect symbol dependencies and recommend ways to pin or resolve missing symbols during automated builds.
    Context/Constraints: Prefer symbols feed or explicit dependencies in pipeline.
    Desired Output Format: Troubleshooting steps + pipeline snippet to fetch symbols.


UI, pages, role centers & user experience

  1. Role Assignment: Act as a UX-focused senior AL dev.
    Task/Goal: Review Page / PageExtension code for usability and propose changes to improve flow and reduce cognitive load.
    Context/Constraints: Maintain existing fields; avoid heavy OnOpenPage logic.
    Desired Output Format: Bulleted UX issues + code snippets to refactor (FactBox, FastTabs, conditional visibility).

  2. Role Assignment: Act as a RoleCenter designer.
    Task/Goal: Suggest optimal Cues and KPIs for a given role and provide AL code for RoleCenter and Cues.
    Context/Constraints: Use performant queries and avoid FlowFields on RoleCenter.
    Desired Output Format: RoleCenter code + Query or Cue code snippet.

  3. Role Assignment: Act as an accessibility reviewer.
    Task/Goal: Ensure pages and captions are screen-reader friendly and labels are clear.
    Context/Constraints: Use concise captions and ToolTips; avoid ambiguity.
    Desired Output Format: List of accessibility issues + corrected Page snippet and caption examples.

  4. Role Assignment: Act as a page-performance optimizer.
    Task/Goal: Replace synchronous heavy OnOpenPage logic with Job Queue or background tasks.
    Context/Constraints: Provide sample Job Queue code; ensure user feedback for long tasks.
    Desired Output Format: Before/after Page code + Job Queue codeunit snippet.

  5. Role Assignment: Act as an inline-help/documentation engineer.
    Task/Goal: Add contextual help (ToolTips, HelpPage links) to critical fields and actions.
    Context/Constraints: Support multiple languages and short actionable text.
    Desired Output Format: Page extension snippet with ToolTips and Label entries.


Reporting, layouts & data export

  1. Role Assignment: Act as a report performance specialist.
    Task/Goal: Review report object or reportextension for inefficient dataset or grouping and propose improvements.
    Context/Constraints: Support large volumes and pagination where possible.
    Desired Output Format: Optimized report dataset snippet + advice on RDLC vs Word performance.

  2. Role Assignment: Act as a layout/localization reviewer.
    Task/Goal: Make RDLC/Word layout multi-language friendly and minimize layout rendering time.
    Context/Constraints: Keep layout simple and use aggregates where possible.
    Desired Output Format: Layout structuring guidance + sample dataset XML snippet.

  3. Role Assignment: Act as an export-data governance specialist.
    Task/Goal: Ensure CSV/Excel exports in pasted code handle encoding, large row counts and PII redaction.
    Context/Constraints: Stream rows and apply DataClassification rules.
    Desired Output Format: Streaming CSV export AL snippet + PII masking example.

  4. Role Assignment: Act as a scheduled-reporting expert.
    Task/Goal: Convert heavy on-demand report into scheduled Job Queue based report and provide code.
    Context/Constraints: Ensure deliverability (email/SFTP) and retry logic.
    Desired Output Format: Job Queue codeunit + report call snippet + delivery example.

  5. Role Assignment: Act as a dataset-compactness reviewer.
    Task/Goal: Reduce dataset size by selecting only needed fields and using summary items; recommend query usage.
    Context/Constraints: Balance between server-side aggregation and client needs.
    Desired Output Format: Proposed dataset fields list + AL Query or Report dataset snippet.


Integration, JSON, HttpClient & external APIs

  1. Role Assignment: Act as an API reliability architect.
    Task/Goal: Harden pasted HttpClient calls for retries, timeouts, and error classification.
    Context/Constraints: Use exponential backoff and circuit-breaker-like guards.
    Desired Output Format: Robust HttpClient wrapper AL snippet with retry/backoff and logging.

  2. Role Assignment: Act as a JSON robustness engineer.
    Task/Goal: Make JSON parsing resilient to schema changes and missing fields.
    Context/Constraints: Use JsonObject.TryGet and safe conversions.
    Desired Output Format: Safe JSON parsing AL snippet + example of tolerant mapping.

  3. Role Assignment: Act as OAuth/token lifecycle manager.
    Task/Goal: Provide secure token storage and refresh flow for an external API integration.
    Context/Constraints: Minimize exposure and avoid long-lived tokens in code.
    Desired Output Format: Token storage pattern + refresh snippet + secure retrieval code.

  4. Role Assignment: Act as a webhook and event sink expert.
    Task/Goal: Review webhook consumer logic and improve idempotency and dedup handling.
    Context/Constraints: Use unique message Ids and a dedup store table.
    Desired Output Format: Idempotent webhook handler AL snippet + dedup table design.

  5. Role Assignment: Act as a CSV/Import robustness expert.
    Task/Goal: Improve CSV import code to handle malformed rows, encoding issues and resume on failure.
    Context/Constraints: Batch processing with checkpointing.
    Desired Output Format: Robust import codeunit snippet with checkpointing and error log.


Upgrade, migration & versioning

  1. Role Assignment: Act as a UCI upgrade/migration lead.
    Task/Goal: Create an idempotent OnUpgradePerCompany plan for data transformations in the pasted upgrade code.
    Context/Constraints: Support resume on failure and batched execution for large tables.
    Desired Output Format: Upgrade codeunit snippet with batching, logging and checkpointing.

  2. Role Assignment: Act as a deprecation & obsoletion planner.
    Task/Goal: Propose safe deprecation strategy for fields/objects (ObsoleteState usage) and replacement path.
    Context/Constraints: Communicate to partners and keep backward compatibility for N releases.
    Desired Output Format: Obsoletion policy + sample ObsoleteState code + migration note.

  3. Role Assignment: Act as a semantic-versioning enforcer.
    Task/Goal: Map code changes to version increments (major/minor/patch) and produce app.json update guidance.
    Context/Constraints: Ensure compatibility guarantees are clearly documented.
    Desired Output Format: Versioning matrix + PowerShell snippet to update app.json.

  4. Role Assignment: Act as a large-data migration specialist.
    Task/Goal: Recommend patterns to migrate millions of records with minimal downtime.
    Context/Constraints: Use batched background jobs, back-out strategy and integrity checks.
    Desired Output Format: Stepwise migration plan + AL job queue snippet for batched migration.

  5. Role Assignment: Act as a release-readiness auditor.
    Task/Goal: Run a checklist-based review of the pasted extension for production readiness (UCI checklist: security, performance, tests, docs, telemetry, permissions).
    Context/Constraints: Provide pass/fail per item and remediation plan for failures.
    Desired Output Format: Checklist with status + prioritized remediation tasks + code snippets for critical fixes.

Continue Reading...

Prompt Engineering


The best prompts will follow a simple structure:

  Role Assignment + Clear Task/Goal + Context/Constraints + Desired Output Format.

Remember these three core principles when writing your prompts:

  1. Define the Role (Persona): AI ko batao ki use kya ban-na hai (e.g., Senior AL Developer, Git Expert). This sets the tone and expertise.

  2. Be Specific (Clarity): Vague mat raho. Clearly mention Object Type (Table Extension, Page Extension), Object ID, Field Names, and exact requirement.

  3. Define the Output (Constraint): AI ko batao ki output kaisa chahiye (e.g., "Only provide the AL code block", "Step-by-step instructions").

Prompt IDScenarioRole and Prompt Example (Hinglish/English)
1Table ExtensionAct as a Senior BC AL developer. Create a table extension for the Customer table adding field "GST Registration No." with classification EndUserIdentifiableInformation. Provide only AL code.
2Codeunit FunctionAct as an AL expert. Write a function CalculateDiscount(SalesLineAmount: Decimal) that returns amount after 10% discount. Briefly explain.
3Page ExtensionAct as AL UI specialist. Extend Item Card (Page 30) with a new FastTab "Technical Details" after Invoicing FastTab including group Custom Specs. Provide code only.
4Report Data ItemAct as BC Report Developer. Generate minimal DataItem section joining Sales Header (ID 36) and Sales Line on Document No. Use proper data item links.
5Fix Compile ErrorAct as AL debugger. Fix the error: 'The name MyProcedure does not exist'. Provide fixed code snippet and explanation why error occurred.
6Best Practice RefactoringAct as BC Best Practice Consultant. Refactor a complex AL procedure for readability and naming conventions. Provide refactored code in block.
7Event SubscriberAct as Events Expert. Write codeunit subscribing OnAfterInsertEvent of Vendor table. Check Vendor.Blocked and log application message if true.
8Git Conflict ResolutionAct as Git Expert. Resolve merge conflict in AL_Object_1.al between feature/new-module and main branch step-by-step in VS Code.
9Azure DevOps PipelineAct as DevOps Engineer. Provide basic YAML pipeline structure using AL-Go steps for BC AL extension build and publish.
10Performance AnalysisAct as Performance Analyst. Provide troubleshooting steps for slow Sales Order List page in BC using Performance Toolkit and Custom telemetry.
11Upgrade AnalysisAct as BC Upgrade Specialist. List top 3 AL breaking changes upgrading v24 to v25 with short examples for each.
12PowerShell ScriptingAct as automation specialist. Write PowerShell command using AL-Go to clean AL project, build extension, and create test package.
13GitHub FlowAct as Git Master. Describe standard Git flow for new feature branch: branch creation, commit, pull request for main branch in 4 commands.
14Debugging StrategyAct as Debugging Mentor. Explain how to set AL breakpoint and debug in Cloud Sandbox from VS Code with key steps.
15API IntegrationAct as AL developer. Generate AL code to call an external REST API and parse JSON response. Provide sample code and explanation.
16Batch Job CreationAct as AL developer. Create a batch job to run a specific report nightly. Include scheduling code only.
17Permission Set CreationAct as Security Consultant. Write AL code to create custom Permission Set for a new role with specific object accesses. Provide XML snippet.
18Page Action ExtensionAct as AL UI Developer. Add a new action to Customer List page to open a custom report. Provide only AL action code.
19Table Relation SetupAct as AL developer. Define a relation between Sales Line and Item tables ensuring referential integrity. Show AL keys and properties.
20Data ValidationAct as AL developer. Implement field validation on Credit Limit field in Customer table. Provide AL code and logic explanation.
21Custom NotificationAct as AL developer. Write code to show custom notification message when a user opens a specific page. Provide code example.
22Extension InstallationAct as AL developer. Explain steps to publish and install an AL extension on a BC SaaS environment. Provide PowerShell commands.
23UI CustomizationAct as AL UI specialist. Modify List page layout to add new sortable column. Provide AL page extension code.
24Debugging TipsAct as AL mentor. List top 5 debugging tips for AL coding in Visual Studio Code. Add brief description for each tip.
25Workflow AutomationAct as AL Developer. Generate AL workflow code for automated approval of sales orders over a threshold. Include code and explanation.
26LocalizationAct as AL developer. Add localization support for a custom label in AL extension. Provide example AL labels and resource file.
27Source Control Best PracticesAct as Git expert. List best practices for managing AL code in source control including branching and commit messages.
28Error HandlingAct as AL developer. Implement try-catch style error handling in AL codeunit function. Show code example and error logging strategy.
29Data Migration ScriptsAct as AL developer. Write AL code snippet to migrate data from old table to new extension table. Provide step-by-step explanation.
30Performance OptimizationAct as AL performance expert. Suggest AL coding practices to optimize database queries in complex reports. Provide examples.
31Security Roles SetupAct as BC Security Consultant. Define custom roles with specific page and report permissions in AL. Provide example code snippet.
32Event PublisherAct as AL developer. Create new event publisher in a codeunit and subscriber in another codeunit. Provide example code for both.
33Code DocumentationAct as AL mentor. Show best practices for documenting AL code using comments and XML documentation tags. Provide example block.
34Unit TestingAct as AL developer. Write unit test for a function calculating discounts. Provide code and explanation of test assertions.
35Custom Report DesignAct as AL Report Developer. Define a custom report layout with grouped sections and custom headers. Provide AL RDLC layout snippet.
36Using Table FiltersAct as AL developer. Write code to apply complex filters on Sales Line table programmatically. Provide AL code snippet.
37Integration with Power BIAct as AL developer. Describe approach and AL code to export Business Central data for Power BI dashboards.
38Adaptive Cards NotificationAct as AL developer. Send Adaptive Card notifications via Microsoft Teams using AL extension. Provide example code.
39Recurring Job SetupAct as AL developer. Setup recurring job queue entries for automated processing. Provide minimal AL code examples.
40Data EncryptionAct as Security Expert. Implement encryption for sensitive fields in AL extension. Show sample encryption and decryption code.
41Multi-Currency HandlingAct as AL developer. Handle transactions in multiple currencies with proper exchange rate application. Provide example code.
42Integration with Azure Logic AppsAct as AL developer. Write code to send data from AL to Azure Logic Apps via HTTP. Provide example snippet.
43Background ProcessingAct as AL developer. Implement background processing for long-running tasks with status tracking. Provide example AL code.
44Copy-Paste Code SnippetsAct as AL developer. Provide a collection of reusable AL code snippets for common tasks like date handling, string manipulation, etc.
45Notification SetupAct as AL developer. Send custom notifications to users based on event triggers. Provide example codeunit.
46Workspace Setup for ALAct as AL mentor. Describe best practices for setting up Visual Studio Code workspace for AL projects with extensions.
47Automated DocumentationAct as AL developer. Use tools or extensions to generate documentation automatically from AL code. Provide brief guide.
48Pack and Publish ExtensionAct as AL developer. Define steps to package, version, and publish an AL extension to AppSource or private repository.
49Code Review ChecklistAct as AL mentor. Provide a checklist for reviewing AL code for best practices before merge or deployment.
50Troubleshooting Common IssuesAct as AL mentor. List common AL errors and troubleshooting tips with sample resolutions.



1. Table Extension for New Field

Prompt:
"Act as a Senior Business Central AL Developer. Create an AL table extension for the Customer table. Add a field named 'GST Registration No.' with data type Code and data classification EndUserIdentifiableInformation. Provide only the complete AL code block."


2. Function to Calculate Discounted Sales Line Amount

Prompt:
"Act as an expert AL Coder. Write a Codeunit function CalculateDiscountedSalesLineAmount(SalesLineAmount: Decimal) that returns SalesLineAmount - (SalesLineAmount * 0.10). Briefly explain how this function works."


3. Page Extension to Add FastTab

Prompt:
"Act as an AL UI Specialist. Write an AL Page Extension for the Item Card (Page 30). Add a new FastTab called 'Technical Details' immediately after the 'Invoicing' FastTab. Inside this FastTab, add a group named 'Custom Specs'. Provide only the AL code without explanation."


4. Minimal Report DataItem Section for Joined Tables

Prompt:
"Act as a BC Report Developer. Generate the minimal DataItem section of an AL Report object joining Sales Header (ID 36) and Sales Line tables using a data item link on the Document No. Show the AL code for this DataItem section."


5. Fix Compile Error in AL Code

Prompt:
"I am getting a compile error: 'The name MyProcedure does not exist in the current context' in the following code snippet: [paste code here]. Act as an AL debugger, provide the corrected code snippet, and explain the reason for the error."


6. Best Practice Refactoring of Procedure

Prompt:
"Act as a BC Best Practice Consultant. Review this AL procedure code: [paste long/complex procedure]. Suggest refactorings to improve readability and follow naming conventions. Provide the refactored code only."


7. Event Subscriber for Vendor Table After Insert

Prompt:
"Act as an Events Expert. Write an AL codeunit with a function subscribed to the OnAfterInsertEvent of the Vendor table. Inside the subscriber, check if Vendor.Blocked is true, and if so, log a message to the application log. Provide code only."


8. Git Conflict Resolution Steps in VS Code

Prompt:
"Act as a Git Expert. A merge conflict occurred in file AL_Object_1.al when merging feature/new-module into main branch. Provide step-by-step conflict resolution instructions to fix this in VS Code."


9. Azure DevOps YAML Pipeline for BC Extension

Prompt:
"Act as a DevOps Engineer. Provide a basic YAML pipeline structure for an Azure DevOps build pipeline of a Business Central AL extension using AL-Go. Focus on defining jobs and steps only."


10. Performance Troubleshooting for Slow BC Page

Prompt:
"Act as a Performance Analyst. User reports that the Sales Order List page loads slowly. Suggest troubleshooting steps for an AL developer starting from using Performance Toolkit and Custom telemetry."

๐Ÿงฑ Prompt Template Format

Role Assignment: Define who ChatGPT should act as (expert role).
Task/Goal: Define the exact outcome you want.
Context/Constraints: Add object name, BC version, coding rules, or style constraints.
Desired Output Format: Define how the output should appear (code, explanation, table, etc.).

๐Ÿง  TOP 50 BUSINESS CENTRAL AL PROMPT ENGINEERING EXAMPLES


๐Ÿงฉ CODE CREATION & EXTENSION STRUCTURE

  1. Create a New AL Table

    ๐Ÿ’ก Scenario: You need a new custom table for “Salesperson Target Setup”.
    Prompt:
    “Generate a Business Central AL table object for ‘Salesperson Target Setup’ with fields: Salesperson Code (Code20), Target Amount (Decimal), Month (Date). Include keys, DataClassification, and caption formatting best practices.”


  1. Create a Page for Custom Table

    “Create a List and Card page for table ‘Salesperson Target Setup’. Include page actions for New, Edit, and Delete and use proper ApplicationArea and ToolTip for each field.”


  1. Create a Report Layout

    “Generate an AL report object for listing Customer Ledger Entries filtered by Posting Date. Include totals at the bottom. Provide dataset and layout XML structure.”


  1. Table Extension

    “Extend the ‘Sales Header’ table to add field ‘Custom Order Type (Code20)’ and make it visible on the Sales Order page under the General FastTab.”


  1. Page Extension

    “Extend ‘Customer Card’ page to show field ‘Credit Rating (Integer)’ in a new FastTab named ‘Credit Info’. Include a tooltip and editable=false property.”


  1. Codeunit Template

    “Generate a standard AL Codeunit template for reusable functions like logging or validation. Include OnRun, local/global procedure example, and region formatting.”


  1. Enum Creation

    “Create an Enum named ‘Order Source Type’ with values: Manual, EDI, API, and Partner Portal. Mark it extensible and link a caption for each.”


  1. Interface Example

    “Create an AL interface for ‘IOrderProcessor’ defining methods ValidateOrder, PostOrder, and SendNotification with proper signatures.”


⚙️ CODE OPTIMIZATION & PERFORMANCE

  1. Optimize a Loop

    “Review this AL loop and optimize for performance by reducing database reads: [paste code]. Suggest improvements.”


  1. Query Optimization

“Given this query object [paste code], optimize it for large datasets and explain index/key considerations.”


  1. Refactor Codeunit

“Refactor this codeunit to follow SOLID principles and modularize logic using single-responsibility. [paste code].”


  1. Caching Suggestions

“Suggest how to cache frequent lookups in this code to reduce database calls: [paste code].”


  1. Performance Benchmark

“Give me a test procedure to benchmark runtime performance for this function: [paste code].”


๐Ÿงพ EVENTS, SUBSCRIPTIONS, AND EXTENSIBILITY

  1. Publisher Event Example

“Create an OnBeforeValidate event publisher for the ‘Customer Card’ page to allow other extensions to override default behavior.”


  1. Event Subscriber Template

“Write an AL event subscriber for OnAfterPostSalesDoc event in ‘Sales Post Codeunit’. Include best practices for naming and local variables.”


  1. Custom Event Model

“Design a proper event model for custom extension ‘Expense Approval Workflow’ to expose extensibility points.”


  1. Find Available Events

“List standard events in the ‘Item Journal Post Line’ codeunit that can be used to extend posting logic.”


  1. Event Best Practice

“Explain the difference between IntegrationEvent and BusinessEvent in AL and when to use each.”


๐Ÿงฐ DEBUGGING & ERROR HANDLING

  1. Error Handling Template

“Give me a reusable AL function pattern for TRY-CATCH error handling with clear messages using GetLastErrorText().”


  1. Debug Scenario

“Explain how to debug an extension deployed to Sandbox with Visual Studio Code step-by-step.”


  1. Log Framework

“Generate an AL logging module to record user actions in a custom Log table. Include procedure LogAction(UserID, Action, Description).”


  1. Telemetry Integration

“Explain how to use the Session.LogMessage method for custom telemetry logging in AL.”


๐Ÿงฎ BUSINESS LOGIC AUTOMATION

  1. Sales Discount Calculation

“Write a function in AL to calculate progressive discounts (10% up to ₹10,000, 15% above ₹10,000). Return total discount amount.”


  1. Auto-Numbering Function

“Generate a procedure to auto-generate a running document number using a ‘No. Series’ setup.”


  1. Approval Workflow

“Design AL codeunit structure for ‘Expense Approval Workflow’ using workflow events and approval entries.”


  1. Validation Function

“Write a function ValidateCustomerCreditLimit(SalesHeader) that blocks posting if outstanding > CreditLimit.”


  1. Scheduled Job Queue Example

“Create a codeunit that runs as a Job Queue to auto-close old service orders older than 60 days.”


๐Ÿงฉ INTEGRATION & API

  1. API Page Example

“Create a custom API page for ‘Sales Order Summary’ exposing fields: Order No., Customer Name, Total Amount, and Status.”


  1. Webhook Example

“Show how to send a JSON payload to an external API using HttpClient when a Sales Invoice is posted.”


  1. OAuth2 Integration

“Explain and generate AL code for connecting to an external REST API using OAuth2 authentication.”


  1. JSON Parsing

“Write AL code to parse this JSON response [paste JSON] and insert data into custom ‘Integration Log’ table.”


  1. File Upload Example

“Generate AL example for uploading a CSV file and reading its contents using FileManagement codeunit.”


๐Ÿ” GIT / DEVOPS / DEPLOYMENT

  1. Git Branching Workflow

“Suggest an ideal Git branching strategy for a Business Central AL extension project (Dev, Test, UAT, Prod).”


  1. PowerShell Deployment Script

“Generate PowerShell script to publish .app file to BC environment using bccontainerhelper or AL-Go style.”


  1. AL-Go CI/CD Pipeline

“Explain how to set up AL-Go for GitHub for automated build and test of my AL extension.”


  1. Automated Versioning

“Give AL code or PowerShell logic to auto-increment version number on each pipeline run.”


  1. Symbol Reference Issue

“Help me fix the error ‘Symbol not found: Table 27’ during build; guide me how to resolve symbol reference issues.”


  1. Docker Sandbox Setup

“Guide me to set up Business Central Docker Sandbox with my extension deployed automatically.”


๐Ÿ” TESTING

  1. Test Codeunit Example

“Generate AL test codeunit for validating ‘Customer Creation’ logic using ASSERT statements.”


  1. Test Isolation

“Explain how to isolate data for each test method using TestSuite in AL.”


  1. Mock Data Example

“Generate mock data creation procedure for ‘Item’ and ‘Customer’ for testing scenarios.”


  1. Code Coverage

“Explain how to enable code coverage in BC test framework and export results.”


๐Ÿงฎ DATA MIGRATION & UTILITIES

  1. CSV Import Helper

“Write AL codeunit for importing Customer Master data from CSV into Customer table.”


  1. Data Upgrade Codeunit

“Create an upgrade codeunit to migrate old ‘Custom Field’ data from v1.0 to v2.0.”


  1. Background Processing

“Show how to use Task Scheduler to process records asynchronously in background.”


๐Ÿ“š DOCUMENTATION & STANDARDS

  1. Naming Convention Reference

“Provide AL naming conventions for variables, procedures, tables, and pages aligned with Microsoft AL guidelines.”


  1. Code Commenting Template

“Generate a standard header and inline comment template for AL codeunits and pages.”


  1. Documentation Generator

“Create a PowerShell or AL script that extracts object names and descriptions to generate documentation.”


๐Ÿ’ก ADVANCED / CUSTOM SCENARIOS

  1. Event-Driven Architecture

“Design an event-driven AL extension architecture for a modular invoicing system with 3 custom modules.”


  1. AI Assistant Integration

“Suggest how to integrate an external AI API (like Azure OpenAI) with BC using AL and custom API page for internal automation.”


⚡ 50 AI PROMPTS FOR BUSINESS CENTRAL AL DEVELOPERS (Productivity-Focused)


๐Ÿ”น 1. Create New AL Table

Role Assignment: Act as a senior Business Central AL solution architect.
Task/Goal: Create a new AL table object named “Salesperson Target Setup”.
Context/Constraints: Include fields Salesperson Code (Code20), Target Amount (Decimal), Month (Date). Add keys, captions, and DataClassification attributes.
Desired Output Format: Provide clean AL code with comments explaining each field.


๐Ÿ”น 2. Generate List Page

Role Assignment: Act as a Business Central AL UI designer.
Task/Goal: Build a List page for table "Salesperson Target Setup".
Context/Constraints: Use proper ApplicationArea, ToolTips, and action triggers.
Desired Output Format: Complete AL page object code ready to compile.


๐Ÿ”น 3. Create Card Page

Role Assignment: Act as a UI/UX-oriented AL developer.
Task/Goal: Build a Card page for “Salesperson Target Setup”.
Context/Constraints: Use FactBox area, grouping, and FastTabs for better readability.
Desired Output Format: AL code with detailed layout and comments.


๐Ÿ”น 4. Extend Table

Role Assignment: Act as an AL extensibility expert.
Task/Goal: Extend table “Sales Header” to add a new field “Custom Order Type (Code20)”.
Context/Constraints: Use appropriate DataClassification and positioning in a logical sequence.
Desired Output Format: AL tableextension object code.


๐Ÿ”น 5. Extend Page

Role Assignment: Act as a Business Central page customization specialist.
Task/Goal: Extend “Customer Card” page to show field “Credit Rating (Integer)” under a new FastTab.
Context/Constraints: Read-only, ApplicationArea=All.
Desired Output Format: AL pageextension code snippet.


๐Ÿ”น 6. Create Codeunit Template

Role Assignment: Act as an AL code library designer.
Task/Goal: Generate a reusable AL codeunit structure for utility functions (e.g., logging, validation).
Context/Constraints: Must include regions, OnRun(), and example local/global procedures.
Desired Output Format: AL code with documentation comment header.


๐Ÿ”น 7. Create Enum

Role Assignment: Act as an AL data modeler.
Task/Goal: Define Enum “Order Source Type” (Manual, API, Portal, EDI).
Context/Constraints: Extensible = true; each value has caption.
Desired Output Format: AL Enum code.


๐Ÿ”น 8. Create Interface

Role Assignment: Act as a Business Central interface designer.
Task/Goal: Define interface “IOrderProcessor” with methods: ValidateOrder(), PostOrder(), SendNotification().
Context/Constraints: Use standard AL interface syntax.
Desired Output Format: AL interface object code.


๐Ÿ”น 9. Optimize Loop Performance

Role Assignment: Act as an AL performance optimization expert.
Task/Goal: Optimize the following AL loop for large datasets.
Context/Constraints: Minimize database reads, use temporary tables if needed.
Desired Output Format: Optimized code version + explanation of improvements.


๐Ÿ”น 10. Query Optimization

Role Assignment: Act as a query optimization specialist.
Task/Goal: Analyze and improve query object for performance.
Context/Constraints: Consider key usage, filters, and FlowFields.
Desired Output Format: Optimized query AL code + reasoning.


๐Ÿ”น 11. Refactor Codeunit

Role Assignment: Act as a clean-code AL architect.
Task/Goal: Refactor codeunit [paste code] following SOLID principles.
Context/Constraints: Improve modularity, readability, and reusability.
Desired Output Format: Refactored codeunit with inline comments.


๐Ÿ”น 12. Cache Lookups

Role Assignment: Act as a performance-oriented AL engineer.
Task/Goal: Suggest caching approach for frequent table lookups in the given AL code.
Context/Constraints: Maintain functional correctness; use temporary variables or single-instance codeunit if required.
Desired Output Format: Revised code snippet with caching + explanation.


๐Ÿ”น 13. Benchmark Performance

Role Assignment: Act as a testing automation engineer.
Task/Goal: Write AL code to benchmark execution time of a function.
Context/Constraints: Use Time functions and log output to message or table.
Desired Output Format: AL test procedure example.


๐Ÿ”น 14. Add Publisher Event

Role Assignment: Act as an extensibility architect.
Task/Goal: Add an OnBeforeValidate publisher in Customer table.
Context/Constraints: Use IntegrationEvent and ensure parameters are VAR.
Desired Output Format: AL event publisher code with comments.


๐Ÿ”น 15. Create Event Subscriber

Role Assignment: Act as an AL subscriber developer.
Task/Goal: Subscribe to event OnAfterPostSalesDoc in Sales Post Codeunit.
Context/Constraints: Proper naming, EventSubscriberAttribute, use global scope where needed.
Desired Output Format: AL event subscriber procedure code.


๐Ÿ”น 16. Workflow Event Design

Role Assignment: Act as a Business Central workflow designer.
Task/Goal: Design event flow for custom “Expense Approval” system.
Context/Constraints: Include publisher, subscriber, and status update event chain.
Desired Output Format: High-level diagram + sample AL code snippets.


๐Ÿ”น 17. Find Standard Events

Role Assignment: Act as an AL API reference expert.
Task/Goal: List available integration events in “Item Journal Post Line” codeunit.
Context/Constraints: Include event names and parameters.
Desired Output Format: Table format listing Event Name + Description.


๐Ÿ”น 18. Explain Event Types

Role Assignment: Act as a Microsoft AL documentation expert.
Task/Goal: Explain difference between IntegrationEvent and BusinessEvent.
Context/Constraints: Include use-cases from real BC extensions.
Desired Output Format: Structured comparison table + summary.


๐Ÿ”น 19. TRY-CATCH Template

Role Assignment: Act as an AL error-handling specialist.
Task/Goal: Write TRY-CATCH pattern using GetLastErrorText().
Context/Constraints: Follow best practices for displaying user-friendly errors.
Desired Output Format: AL code with example usage.


๐Ÿ”น 20. Debug Guide

Role Assignment: Act as a Business Central debugging instructor.
Task/Goal: Explain step-by-step how to debug AL code on a Sandbox via VS Code.
Context/Constraints: Include launch.json setup and breakpoints.
Desired Output Format: Step list with screenshots reference or notes.


๐Ÿ”น 21. Logging Framework

Role Assignment: Act as an AL logging framework designer.
Task/Goal: Design reusable LogAction(UserID, Action, Description) function.
Context/Constraints: Store in custom “Log Entries” table; use Insert(true).
Desired Output Format: Table + Codeunit AL code.


๐Ÿ”น 22. Add Telemetry

Role Assignment: Act as a telemetry integration expert.
Task/Goal: Use Session.LogMessage for custom telemetry events.
Context/Constraints: Add meaningful message IDs and event types.
Desired Output Format: AL code example.


๐Ÿ”น 23. Discount Calculation

Role Assignment: Act as a business rule automation developer.
Task/Goal: Write function to calculate discount based on amount tiers.
Context/Constraints: <10,000 = 10%; >=10,000 = 15%.
Desired Output Format: AL procedure returning decimal discount.


๐Ÿ”น 24. Auto Document Numbering

Role Assignment: Act as a numbering system expert.
Task/Goal: Auto-generate running number using No. Series.
Context/Constraints: Error if no series found.
Desired Output Format: AL function code.


๐Ÿ”น 25. Approval Workflow

Role Assignment: Act as an AL workflow implementer.
Task/Goal: Build approval logic for “Expense Request”.
Context/Constraints: Use workflow events and approval entries.
Desired Output Format: Codeunit + step explanation.


๐Ÿ”น 26. Credit Limit Validation

Role Assignment: Act as a functional AL developer.
Task/Goal: Prevent posting if Customer outstanding > CreditLimit.
Context/Constraints: Validate on Sales Header OnBeforePost.
Desired Output Format: AL code example.


๐Ÿ”น 27. Job Queue Task

Role Assignment: Act as a background task automation expert.
Task/Goal: Create job queue codeunit that closes orders older than 60 days.
Context/Constraints: Use Record.FindSet and Modify().
Desired Output Format: AL job queue codeunit.


๐Ÿ”น 28. API Page

Role Assignment: Act as a Business Central API designer.
Task/Goal: Build custom API page exposing Sales Order summary.
Context/Constraints: Include header fields only, JSON endpoint format.
Desired Output Format: AL API page code.


๐Ÿ”น 29. Webhook Call

Role Assignment: Act as an integration engineer.
Task/Goal: Send JSON payload to API after Sales Invoice posting.
Context/Constraints: Use HttpClient, Headers, and Post method.
Desired Output Format: AL code with JSON sample.


๐Ÿ”น 30. OAuth2 Example

Role Assignment: Act as an external API integration expert.
Task/Goal: Connect to an external API with OAuth2.
Context/Constraints: Use HttpClient, store tokens securely.
Desired Output Format: AL code + explanation.


๐Ÿ”น 31. Parse JSON

Role Assignment: Act as an AL data transformation specialist.
Task/Goal: Parse given JSON and insert data into custom table.
Context/Constraints: Use JsonObject, JsonArray, and Evaluate().
Desired Output Format: AL code example.


๐Ÿ”น 32. File Upload

Role Assignment: Act as a file handling expert.
Task/Goal: Upload CSV file and read contents into temporary record.
Context/Constraints: Use FileManagement codeunit.
Desired Output Format: AL codeunit example.


๐Ÿ”น 33. Git Branch Strategy

Role Assignment: Act as a DevOps coach for AL developers.
Task/Goal: Define branching strategy for multi-environment AL project.
Context/Constraints: Dev → Test → UAT → Prod flow.
Desired Output Format: Diagram + branch naming conventions.


๐Ÿ”น 34. PowerShell Deployment

Role Assignment: Act as a BC DevOps automation engineer.
Task/Goal: Generate PowerShell script to publish .app file.
Context/Constraints: Use bccontainerhelper Publish-BCContainerApp.
Desired Output Format: PowerShell script with comments.


๐Ÿ”น 35. AL-Go CI/CD Setup

Role Assignment: Act as CI/CD pipeline architect.
Task/Goal: Configure GitHub Actions using AL-Go template.
Context/Constraints: Auto build + test extension on push.
Desired Output Format: YAML file snippet.


๐Ÿ”น 36. Auto Versioning

Role Assignment: Act as a release automation engineer.
Task/Goal: Increment app.json version automatically on each pipeline.
Context/Constraints: Maintain major.minor.build format.
Desired Output Format: PowerShell snippet.


๐Ÿ”น 37. Fix Symbol Error

Role Assignment: Act as a build troubleshooting expert.
Task/Goal: Fix “Symbol not found: Table 27” issue during compile.
Context/Constraints: Explain missing dependencies and resolution steps.
Desired Output Format: Step-by-step fix guide.


๐Ÿ”น 38. Docker Sandbox

Role Assignment: Act as BC Docker container expert.
Task/Goal: Set up local BC sandbox with extension auto-deploy.
Context/Constraints: Use bccontainerhelper, specify version & artifact URL.
Desired Output Format: PowerShell script.


๐Ÿ”น 39. AL Test Codeunit

Role Assignment: Act as test automation developer.
Task/Goal: Create AL test codeunit to validate Customer creation.
Context/Constraints: Use ASSERT statements.
Desired Output Format: AL test codeunit.


๐Ÿ”น 40. Test Data Isolation

Role Assignment: Act as BC test environment designer.
Task/Goal: Ensure isolated test data per test method.
Context/Constraints: Use TestSuite framework.
Desired Output Format: AL example.


๐Ÿ”น 41. Mock Data Generator

Role Assignment: Act as test data generator expert.
Task/Goal: Create mock Item and Customer data.
Context/Constraints: Randomize Code, Name, and Balance.
Desired Output Format: AL helper codeunit.


๐Ÿ”น 42. Code Coverage Report

Role Assignment: Act as a QA automation specialist.
Task/Goal: Enable code coverage and export results.
Context/Constraints: Use BC Test Tool.
Desired Output Format: Command steps.


๐Ÿ”น 43. CSV Import

Role Assignment: Act as a data migration engineer.
Task/Goal: Import Customer data from CSV file.
Context/Constraints: Map fields, handle errors gracefully.
Desired Output Format: AL codeunit.


๐Ÿ”น 44. Data Upgrade

Role Assignment: Act as upgrade codeunit designer.
Task/Goal: Migrate data from custom field v1.0 to v2.0.
Context/Constraints: Use OnUpgradePerCompany().
Desired Output Format: AL upgrade codeunit.


๐Ÿ”น 45. Task Scheduler

Role Assignment: Act as background processing expert.
Task/Goal: Execute async task to process pending records.
Context/Constraints: Use TaskScheduler codeunit.
Desired Output Format: AL code snippet.


๐Ÿ”น 46. Naming Standards

Role Assignment: Act as AL coding standards coach.
Task/Goal: Define naming rules for variables, tables, pages, enums.
Context/Constraints: Follow Microsoft guidelines.
Desired Output Format: Table of naming conventions.


๐Ÿ”น 47. Comment Template

Role Assignment: Act as a documentation expert.
Task/Goal: Generate code comment header and inline style.
Context/Constraints: Use consistent block header format.
Desired Output Format: Example template.


๐Ÿ”น 48. Documentation Extractor

Role Assignment: Act as DevOps documentation specialist.
Task/Goal: Extract all object names and descriptions into a CSV.
Context/Constraints: Use PowerShell AL object scanning.
Desired Output Format: Script + sample output.


๐Ÿ”น 49. Modular Architecture

Role Assignment: Act as extension architect.
Task/Goal: Design modular invoicing extension using events.
Context/Constraints: Separate Posting, Validation, and Notification modules.
Desired Output Format: Diagram + event flow.


๐Ÿ”น 50. AI API Integration

Role Assignment: Act as AI integration architect.
Task/Goal: Connect Business Central to an external AI API (e.g., Azure OpenAI) for suggestion generation.
Context/Constraints: Use AL HttpClient + secure key handling.
Desired Output Format: AL code + explanation.


⚡ 50 BEST AI PROMPT EXAMPLES FOR BUSINESS CENTRAL AL DEVELOPERS

(Grouped by Object Type)


๐Ÿงฉ 1️⃣ TABLE OBJECT PROMPTS (Data Layer Design)


1. Create a new AL Table

Role Assignment: Act as a senior AL data architect.
Task/Goal: Create a new AL table “Sales Target Setup”.
Context/Constraints: Fields: Salesperson Code (Code20), Month (Date), Target Amount (Decimal). Add clustered primary key and captions.
Desired Output Format: AL table object code with comments.


2. Add Field Validation

Role Assignment: Act as a validation expert.
Task/Goal: Add validation trigger on Target Amount field.
Context/Constraints: Amount must be > 0, else throw error.
Desired Output Format: Complete AL table code snippet with trigger.


3. Table Relation Example

Role Assignment: Act as an AL relational design expert.
Task/Goal: Create a table with a field related to “Customer” table.
Context/Constraints: Use TableRelation property and enforce lookup.
Desired Output Format: AL table code showing correct relation syntax.


4. Add FieldGroup

Role Assignment: Act as UI metadata designer.
Task/Goal: Define DropDown field group for “Sales Target Setup”.
Context/Constraints: Include Salesperson Code and Target Amount.
Desired Output Format: Table with FieldGroup definition.


5. DataClassification

Role Assignment: Act as GDPR-compliant developer.
Task/Goal: Apply correct DataClassification to all fields.
Context/Constraints: Follow BC standards (CustomerContent, ToBeClassified, etc.).
Desired Output Format: AL table code with annotated DataClassification.



๐Ÿช„ 2️⃣ TABLE EXTENSION PROMPTS


6. Extend “Customer” Table

Role Assignment: Act as an AL extensibility architect.
Task/Goal: Add field “Customer Segment (Option)” to Customer table.
Context/Constraints: Options: Gold, Silver, Bronze; store as Enum if possible.
Desired Output Format: AL tableextension code.


7. Add FlowField

Role Assignment: Act as data aggregation expert.
Task/Goal: Add FlowField “Total Open Orders” to Customer table.
Context/Constraints: Calculate from Sales Header (Status=Open).
Desired Output Format: AL code with CalcFormula example.


8. Add OnValidate Trigger

Role Assignment: Act as field validation expert.
Task/Goal: Trigger on new field to enforce rule.
Context/Constraints: If Segment = Gold → minimum balance ₹10,000.
Desired Output Format: AL field OnValidate trigger code.


9. Add Obsolete Field

Role Assignment: Act as versioning expert.
Task/Goal: Mark old custom field as Obsolete.
Context/Constraints: Use ObsoleteState and ObsoleteReason.
Desired Output Format: AL code snippet.


10. Add Table Extension for Custom Logic

Role Assignment: Act as custom logic architect.
Task/Goal: Add new Boolean field “Is Verified” to Vendor table.
Context/Constraints: Field editable only if Vendor.Status=Active.
Desired Output Format: Table extension + conditional validation.



๐Ÿ“‹ 3️⃣ PAGE OBJECT PROMPTS


11. Create List Page

Role Assignment: Act as BC page UI designer.
Task/Goal: Create List page for “Sales Target Setup”.
Context/Constraints: Include filters, ApplicationArea, and actions.
Desired Output Format: Full AL page object.


12. Create Card Page

Role Assignment: Act as UX-oriented AL developer.
Task/Goal: Create Card page for the same table.
Context/Constraints: Group fields logically, use FastTabs.
Desired Output Format: AL code.


13. Add FactBox

Role Assignment: Act as FactBox designer.
Task/Goal: Add FactBox showing Customer Balance in “Customer Card”.
Context/Constraints: Use Part and SubPageLink properties.
Desired Output Format: Page extension or composite page code.


14. Page Actions

Role Assignment: Act as UI action designer.
Task/Goal: Add “Recalculate Target” action button on List page.
Context/Constraints: Runs codeunit function on click.
Desired Output Format: Page action AL code.


15. Add Page Filter

Role Assignment: Act as usability expert.
Task/Goal: Apply filter to show only current month’s records.
Context/Constraints: Use OnOpenPage trigger.
Desired Output Format: AL code snippet.



๐Ÿงฑ 4️⃣ PAGE EXTENSION PROMPTS


16. Extend “Customer Card” Page

Role Assignment: Act as page extension developer.
Task/Goal: Add new FastTab “Customer Segment Info”.
Context/Constraints: Display fields Segment and LoyaltyPoints.
Desired Output Format: Page extension code.


17. Add Action Group

Role Assignment: Act as UX consistency expert.
Task/Goal: Add new ActionGroup “Customer Tools”.
Context/Constraints: Contain actions for Custom Reports.
Desired Output Format: Page extension AL snippet.


18. Add Cue to RoleCenter

Role Assignment: Act as role-based designer.
Task/Goal: Add Cue for “Pending Sales Targets” on RoleCenter.
Context/Constraints: Use FlowField and Count triggers.
Desired Output Format: CueGroup AL code.


19. Modify Existing Field Behavior

Role Assignment: Act as AL refactoring specialist.
Task/Goal: Change visibility of “Blocked” field based on custom condition.
Context/Constraints: Editable=false if Status=Inactive.
Desired Output Format: Page extension code.


20. Add Tooltip and Help

Role Assignment: Act as documentation-friendly developer.
Task/Goal: Add tooltip for “Credit Rating” field in Customer page.
Context/Constraints: Tooltip should describe rating logic.
Desired Output Format: Updated field code snippet.



๐Ÿงฎ 5️⃣ REPORT OBJECT PROMPTS


21. Create Report Dataset

Role Assignment: Act as report data designer.
Task/Goal: Build report showing Customer-wise Sales Summary.
Context/Constraints: Use Sales Invoice Header/Line tables.
Desired Output Format: AL report object.


22. Add RDLC Layout

Role Assignment: Act as report designer.
Task/Goal: Include totals and grouping in layout.
Context/Constraints: Provide XML layout dataset structure.
Desired Output Format: AL + layout XML code.


23. Request Page Filters

Role Assignment: Act as AL filter designer.
Task/Goal: Add filters for Customer, Date Range on RequestPage.
Context/Constraints: Use proper Caption and ToolTip.
Desired Output Format: AL code snippet.


24. Report OnAfterGetRecord Logic

Role Assignment: Act as report logic developer.
Task/Goal: Add custom calculation in OnAfterGetRecord.
Context/Constraints: Calculate margin percentage.
Desired Output Format: AL code with calculation.


25. Report Extension

Role Assignment: Act as extensibility expert.
Task/Goal: Extend standard “Customer - Top 10 List” report to include “Region” column.
Context/Constraints: Use reportextension object.
Desired Output Format: AL reportextension code.



๐Ÿง  6️⃣ CODEUNIT PROMPTS (Logic Layer)


26. Create Utility Codeunit

Role Assignment: Act as AL modular developer.
Task/Goal: Create reusable “Helper Functions” codeunit.
Context/Constraints: Include example procedure for date difference.
Desired Output Format: AL codeunit code.


27. Create Posting Codeunit

Role Assignment: Act as process automation expert.
Task/Goal: Develop custom posting routine for Expense Entry.
Context/Constraints: Include validation, ledger posting, and commit pattern.
Desired Output Format: AL codeunit with comments.


28. Add Event Publisher

Role Assignment: Act as event-driven architect.
Task/Goal: Add IntegrationEvent “OnBeforePostExpense()”.
Context/Constraints: Use [IntegrationEvent(false, false)].
Desired Output Format: AL event publisher snippet.


29. Add Event Subscriber

Role Assignment: Act as extension subscriber designer.
Task/Goal: Subscribe to OnBeforePostExpense event.
Context/Constraints: Use EventSubscriber attribute and handle logic.
Desired Output Format: AL codeunit snippet.


30. Logging Function

Role Assignment: Act as audit log implementer.
Task/Goal: Add procedure LogUserAction(UserID, Action, Description).
Context/Constraints: Store in “Log Entries” table.
Desired Output Format: AL function code.



๐Ÿ“Š 7️⃣ QUERY OBJECT PROMPTS


31. Create Query Object

Role Assignment: Act as AL query designer.
Task/Goal: Build query combining “Sales Header” and “Customer”.
Context/Constraints: Include Customer Name, Order Total.
Desired Output Format: AL query object.


32. Add Totals in Query

Role Assignment: Act as data summarization expert.
Task/Goal: Include SUM(Total Amount) grouped by Customer.
Context/Constraints: Use DataItemLink and MethodType=Sum.
Desired Output Format: AL query code.


33. Query for Dashboard

Role Assignment: Act as RoleCenter query designer.
Task/Goal: Build query showing Pending Orders by Status.
Context/Constraints: Sort by Order Date descending.
Desired Output Format: AL query code.


34. Query as API

Role Assignment: Act as API integration expert.
Task/Goal: Expose query results via API.
Context/Constraints: Make it available using APIPage.
Desired Output Format: Query + APIPage code.


35. Query Performance

Role Assignment: Act as query optimization expert.
Task/Goal: Optimize slow query.
Context/Constraints: Minimize data joins and use proper keys.
Desired Output Format: Optimized query code.



๐Ÿงพ 8️⃣ ENUM & ENUM EXTENSION PROMPTS


36. Create Enum

Role Assignment: Act as AL Enum designer.
Task/Goal: Define Enum “Customer Segment” with values Gold, Silver, Bronze.
Context/Constraints: Extensible = true.
Desired Output Format: AL Enum code.


37. Extend Existing Enum

Role Assignment: Act as AL extensibility expert.
Task/Goal: Extend “Document Type” Enum to add “Advance Invoice”.
Context/Constraints: EnumExtension = true.
Desired Output Format: EnumExtension code.


38. Enum Usage in Page

Role Assignment: Act as UI developer.
Task/Goal: Use Enum field on Card page.
Context/Constraints: Enum = “Customer Segment”.
Desired Output Format: AL page snippet.


39. Enum to Option Migration

Role Assignment: Act as modernization expert.
Task/Goal: Convert existing Option field to Enum.
Context/Constraints: Keep backward compatibility.
Desired Output Format: Migration code.


40. Enum Caption Localization

Role Assignment: Act as localization engineer.
Task/Goal: Add translated captions for Enum values.
Context/Constraints: Include ENU and DEU examples.
Desired Output Format: Enum AL code with translations.



๐Ÿงฎ 9️⃣ PERMISSIONS, INTERFACE, ROLE CENTER


41. Create PermissionSet

Role Assignment: Act as security specialist.
Task/Goal: Create PermissionSet “SALES_TARGET_EDIT”.
Context/Constraints: Grant insert/modify to Sales Target table.
Desired Output Format: AL PermissionSet code.


42. Create Interface

Role Assignment: Act as abstraction layer designer.
Task/Goal: Define Interface “IExpenseProcessor”.
Context/Constraints: Include Validate, Post, Notify methods.
Desired Output Format: AL interface code.


43. Implement Interface

Role Assignment: Act as polymorphism expert.
Task/Goal: Implement IExpenseProcessor in a concrete codeunit.
Context/Constraints: Implement all defined methods.
Desired Output Format: AL codeunit.


44. Role Center Design

Role Assignment: Act as UI architect.
Task/Goal: Create RoleCenter for “Sales Manager”.
Context/Constraints: Include Cues for Orders, Invoices, Customers.
Desired Output Format: AL RoleCenter code.


45. Add Activity Page

Role Assignment: Act as productivity dashboard designer.
Task/Goal: Add Activity Page for Sales metrics.
Context/Constraints: Combine queries + charts.
Desired Output Format: Page + Cue code.



๐Ÿ’ก ๐Ÿ”Ÿ ADVANCED SCENARIOS (DEVOPS + UTILITIES)


46. Data Upgrade Codeunit

Role Assignment: Act as version migration expert.
Task/Goal: Write OnUpgradePerCompany() to migrate data v1→v2.
Context/Constraints: Preserve key fields.
Desired Output Format: AL codeunit.


47. CSV Import Tool

Role Assignment: Act as data migration expert.
Task/Goal: Import CSV data into custom table.
Context/Constraints: Use FileManagement codeunit.
Desired Output Format: AL codeunit.


48. Telemetry Log Integration

Role Assignment: Act as telemetry developer.
Task/Goal: Log custom telemetry when posting orders.
Context/Constraints: Use Session.LogMessage().
Desired Output Format: AL code snippet.


49. Error Handling Template

Role Assignment: Act as error handling specialist.
Task/Goal: Create TRY-CATCH wrapper for API calls.
Context/Constraints: Show message and store error in log table.
Desired Output Format: AL function code.


50. AI-Driven Suggestion API

Role Assignment: Act as AI integration engineer.
Task/Goal: Create codeunit calling external AI API to suggest discount % for customer.
Context/Constraints: Use HttpClient and JSON handling.
Desired Output Format: AL codeunit example.


Write below text last line of Prompt :

"As a prompt engineer, please review and refine the following prompt. My goal is to achieve more accurate and high-quality results. Feel free to ask any clarifying questions before you start."

Review the following prompt for , optimize it for more accuracy, and ask me any questions before processing (Assume the role of a prompt engineer and review the following prompt for , optimize it for better results)

Please review the following prompt for , optimize it for better results, and ask me any questions before processing. (Assume the role of a prompt engineer and review the following prompt for , optimize it for better results.)

As a prompt engineer, please review and refine this prompt to ensure greater accuracy, quality, and efficiency. Feel free to ask any clarifying questions before you start

Act as a prompt engineer. Review the prompt between the delimiters, identify issues (ambiguity, missing context, conflicting instructions), ask necessary clarifying questions first, then provide an optimized prompt that preserves intent, improves structure, and specifies output format and constraints.




Continue Reading...