bcquality/custom/knowledge/architecture/cmfrt-calls-from-base-table-only.md
BeytullahCengiz88 c72c0ad685 Add CMFRT coding standards documentation and examples
- Introduced guidelines for "one codeunit one global function" architecture to enforce single responsibility in AL code.
- Added best practices and anti-patterns for adding parameters via overloads to maintain backward compatibility.
- Documented the importance of never deleting members in AL and always marking them as obsolete.
- Established the requirement for OnBefore and OnAfter integration events for global procedures to enhance extensibility.
- Defined naming conventions for CMFRT objects, including prefixes and object ID ranges to avoid conflicts.
- Implemented patterns for case statements to ensure all cases are handled, including the necessity of an else clause.
- Introduced the interface injection pattern to allow pluggable operations in table-level code.
- Recommended using Confirm Management for user confirmations to improve testability.
- Established a three-permission set pattern for security to ensure proper access control.
- Created a review skill for CMFRT AL standards to automate compliance checks against established guidelines.
2026-07-02 13:12:09 +00:00

1.8 KiB

bc-version domain keywords technologies countries application-area
all
architecture
codeunit
base-table
entry-point
coupling
architecture
cross-codeunit
subscriber
al
w1
all

CMFRT calls to implementation codeunits from base table only

Description

In the CMFRT extension architecture, all calls to implementation codeunits must originate from the base-table object. No AL object other than the base table may call a CMFRT implementation codeunit directly. Event subscriber codeunits handle platform or application events and call the base table's entry-point procedures — not the implementation codeunit directly. Pages and reports call base-table procedures. This keeps the base table as the single integration point for all business-logic calls and ensures that OnBefore/OnAfter integration events fire consistently regardless of where a workflow begins.

Best Practice

When a subscriber codeunit handles an event and needs to trigger a CMFRT operation, it calls the relevant base-table procedure. When a page action initiates business logic, it calls the base-table procedure. The implementation codeunit is an internal detail of the base table and should never appear in using clauses or variable declarations of pages, reports, or subscriber codeunits.

See sample: cmfrt-calls-from-base-table-only.good.al.

Anti Pattern

Calling an implementation codeunit directly from a page, report, subscriber codeunit, or any object other than the base table. Direct calls bypass the base table's integration events, making the operation invisible to dependent extensions that subscribed to those events. This also creates hidden coupling between the caller and the implementation, which breaks when the implementation codeunit is renamed or replaced under the interface.

See sample: cmfrt-calls-from-base-table-only.bad.al.