Study guide

12.3 Access Modifiers (Public, Internal, Local) & Code Scoping

Microsoft Dynamics 365 Business Central Developer MB-820

Track your progress as you read

Finished sections get a check mark.

1 Chapter 1: Business Central Architecture & Platform Foundation

1.1 Business Central Architecture & Extensions Model 1.2 Customization Lifecycle: Cloud (SaaS) vs. On-Premises 1.3 Base Application, System Application & AppSource

2 Chapter 2: Development Environment & Configuration

2.1: Development Environment Setup: VS Code, AL: Go! Projects & Sandboxes 2.2: AL Configuration Files: app.json & launch.json Parameters 2.3: Multi-Root Workspaces & Project Dependencies

3 Chapter 3: Extension Lifecycle: Debugging, Deployment, Multilanguage & Maintenance

3.1 Debugging & Snapshot Debugging in Visual Studio Code 3.2 Extension Deployment & Schema Synchronization Modes 3.3 Multilanguage Development with XLIFF & Translation Files 3.4 Extension Maintenance, Deprecation & Breaking Changes

4 Chapter 4: Tables, Table Extensions & Data Modeling

4.1: Building Tables, Fields, Keys & Data Types 4.2: Table Extensions & Table Modifications 4.3: FlowFields, FlowFilters & Table Relations 4.4: Enums, Enum Extensions & Extensible Types

5 Chapter 5: Pages, Page Extensions & Role Centers

5.1: Page Types, Anatomy & Control Structure 5.2: Building Card, List & Document Pages 5.3: Page Extensions & Page Customizations 5.4: Role Centers, Headlines & Cue Data Modeling

6 Chapter 6: Reports & Document Generation

6.1 Report Architecture, DataItems & Dataset Design 6.2 Report Layouts: RDLC, Word, Excel & Multilanguage 6.3 Document Reports & Request Page Programming 6.4 Processing-Only Reports & Report Substitutions

7 Chapter 7: XMLports & Data Exchange

7.1 XMLport Architecture, Formats & Properties 7.2 XMLport Node Hierarchy, Triggers & Stream Manipulation

8 Chapter 8: Codeunits, Events, Triggers & Interfaces

8.1 Codeunit Types, Execution & SingleInstance Codeunits 8.2 Events, Publishers, Subscribers & Event Isolation 8.3 Interfaces, Polymorphism & Dynamic Codeunit Invocation 8.4 Installation & Upgrade Codeunits, Data Transfer & Archive

9 Chapter 9: Entitlements, Permissions & Queries

9.1 Permission Sets & Permission Set Extensions 9.2 Inherent Permissions, Inherent Entitlements & Security Scoping 9.3 Query Objects: Joins, Aggregation & Query as Report Data Source

10 Chapter 10: UI Customization, User Assistance & Onboarding

10.1 Profile Objects & Custom Page Views in AL 10.2 User Assistance: ToolTips, Teaching Tips & In-App Tours 10.3 Assisted Setup, Guided Experience & Onboarding Checklists

11 Chapter 11: Business Central Design Patterns & Data Process Model

11.1 Functional Table Types: Master Data, Supplemental & Setup Patterns 11.2 Document Standards: Header, Line, History & Journal Architectures 11.3 Data Process Model & Posting Routine Architecture

12 Chapter 12: AL Language Fundamentals, Data Types & Variables

12.1 AL Syntax, Variable Scope, Primitive & Complex Data Types 12.2 Expressions, Control Flow Statements & Built-in Functions 12.3 Access Modifiers (Public, Internal, Local) & Code Scoping

13 Chapter 13: Data Manipulation, Streams & Error Handling

13.1 Record Operations: Get, FindSet, ModifyAll & Filter Functions 13.2 Streams, File Management & TempBlob 13.3 Error Handling: ErrorInfo, TryFunctions & Collectible Errors

14 Chapter 14: Testing, Test Toolkit & Automation

14.1 Testing Architecture & the Test Toolkit 14.2 Authoring Test Codeunits & UI Handler Functions

15 Chapter 15: Telemetry, Performance Optimization & Analyzers

15.1 Telemetry Configuration & Azure Application Insights 15.2 Custom Telemetry Signals with Session.LogMessage & KQL 15.3 Performance Profiler, SetLoadFields & Query Optimization 15.4 AL Analyzers: CodeCop, AppSourceCop, UICop & PTECop

16 Chapter 16: REST Web Services & JSON in AL

16.1 HttpClient, HttpRequestMessage & REST API Consumption 16.2 JSON Processing: JsonObject, JsonArray, JsonValue & JsonToken

17 Chapter 17: API Pages, OData, Read Scale-Out & OAuth

17.1 API Pages (PageType=API), OData Web Services & REST Endpoints 17.2 Bound and Unbound OData Actions with [ServiceEnabled] 17.3 Read Scale-Out Architecture & DataAccessIntent Configuration 17.4 Microsoft Entra ID App Registrations & OAuth 2.0 Integration

12.3 Access Modifiers (Public, Internal, Local) & Code Scoping

Key Takeaways Explain This Topic AI

AL provides three access levels for objects and procedures: Public, Internal, and Local, controlling encapsulation across extension and module boundaries.

Access = Public is the default for objects, making them accessible to any downstream extension that declares a dependency.

Access = Internal restricts object or procedure visibility strictly to the declaring extension and explicitly authorized friend extensions declared via internalsVisibleTo in app.json.

local procedure restricts procedure invocation strictly to the declaring object file, which is the standard best practice pattern for event publisher declarations.

Setting Extensible = false on tables, pages, or enums prevents downstream third-party extensions from modifying schemas, adding page controls, or injecting unhandled enum ordinals.

Last updated: August 2026

12.3 Access Modifiers (Public, Internal, Local) & Code Scoping

As Business Central extension ecosystems scale into multi-app architectures with complex dependencies, developers must enforce strict software architecture boundaries. AL provides robust access modifiers at both the object level and procedure level , as well as manifest configurations for friend extensions, namespace hierarchies, and explicit extensibility locks. For the MB-820 exam, developers must know how to secure internal logic, encapsulate helper objects, prevent breaking changes, and manage API visibility across extensions.

1. Object-Level Access Modifiers ( Access Property)

Every AL object (table, codeunit, page, report, query, XMLport, interface, enum, permission set) supports the Access property, which dictates its visibility to other extensions installed on the same tenant or compiled in the same workspace. codeunit 50110 "Payment Gateway Internal Core"

  • {
  • Access = Internal;
  • Subtype = Normal;
  • // Codeunit can only be invoked within this extension or declared friend extensions
  • }
  • The Three Object Access Levels

Access Level Syntax Scope & Visibility Mechanics

Public Access = Public; (Default) The object is fully visible and accessible to any downstream extension that declares a dependency on this app in app.json . This is the default if Access is omitted.

Internal Access = Internal; The object is visible only within the declaring extension package and to explicit "friend extensions" authorized in app.json via internalsVisibleTo . Other third-party extensions cannot reference, extend, or call this object.

Local Access = Local; Restricts visibility strictly to the declaring module or local extension package. (Used primarily in modular system and platform packages).

Why Use Access = Internal on Objects?

API Boundary Protection: Expose only clean public facade codeunits while hiding low-level implementation details, database staging tables, and helper algorithms.

Refactoring Freedom: Internal objects can be refactored, renamed, or redesigned in future releases without causing breaking changes for external ISV consumers.

Security & Integrity: Prevents third-party extensions from directly manipulating sensitive configuration tables or bypassing validated business pipelines.

2. Friend Extensions & The internalsVisibleTo Manifest

In modular enterprise solutions, an ISV often splits functionality into multiple distinct extensions (e.g., a shared Core Framework extension, a Sales Logistics extension, and an EDI Integration extension). When the Core Framework marks helper codeunits and internal tables as Access = Internal , companion extensions authored by the same publisher need access to those internal objects without exposing them to third-party developers.

This is achieved by declaring Friend Extensions in the app.json manifest of the declaring extension using the internalsVisibleTo array: {

  • "id": "e3a45678-1234-4a5b-8c9d-0123456789ab",
  • "name": "Contoso Core Framework",
  • "publisher": "Contoso Ltd.",
  • "version": "2.0.0.0",
  • "internalsVisibleTo": [
  • {
  • "id": "f8b76543-4321-4a5b-8c9d-9876543210fe",
  • "name": "Contoso Advanced Logistics",
  • "publisher": "Contoso Ltd."
  • },
  • {
  • "id": "a1b2c3d4-5678-90ab-cdef-1234567890ab",
  • "name": "Contoso E-Commerce Connector",
  • "publisher": "Contoso Ltd."
  • }
  • ]
  • }
  • Rules for Friend Extension Resolution

Exact Manifest Match: The downstream calling extension must have an id (GUID), name , and publisher that strictly match the entry in the declaring extension's internalsVisibleTo manifest.

Dependency Declaration: The friend extension must declare an explicit dependency on the parent extension in its own app.json dependencies list.

Transitive Protection: If Extension B is a friend of Extension A, Extension C (which depends on B) does not automatically inherit access to Extension A's internal objects unless Extension C is also explicitly listed in Extension A's internalsVisibleTo .

Compiler Enforcement: If an unauthorized third-party extension attempts to call an internal object or procedure, the AL compiler rejects the reference with an inaccessibility error — the target is not visible outside its declaring extension.

Loading diagram... AL Access Modifiers & Friend Extension Architecture

3. Procedure-Level Access Modifiers

Procedures defined inside AL objects support three distinct access levels: codeunit 50120 "Inventory Allocation Engine"

  • {
  • Access = Public;
  • // 1. Public Procedure (Default)
  • procedure CalculateAvailableToPromise(ItemNo: Code[20]): Decimal
  • begin
  • // Accessible from any extension that can see this codeunit
  • exit(ComputeNetAvailability(ItemNo));
  • end;
  • // 2. Internal Procedure
  • internal procedure RecalculateSafetyStock(ItemNo: Code[20])
  • begin
  • // Accessible only within this extension and declared friend extensions
  • UpdateBuffer(ItemNo);
  • end;
  • // 3. Local Procedure
  • local procedure ComputeNetAvailability(ItemNo: Code[20]): Decimal
  • begin
  • // Accessible ONLY within this codeunit
  • exit(100.0);
  • end;
  • // Event Publisher pattern (Standard Practice: Local Procedure)
  • [IntegrationEvent(false, false)]
  • local procedure OnAfterAllocationComputed(ItemNo: Code[20]; AllocatedQty: Decimal)
  • begin
  • end;
  • }
  • Procedure Access Level Comparison

Procedure Modifier Syntax Scope & Invocation Rules

Public procedure MethodName() Callable by any object within the same extension, as well as any external extension that has access to the containing object.

Internal internal procedure MethodName() Callable by any object within the declaring extension package and by authorized friend extensions. External third-party extensions cannot call this procedure even if the containing codeunit is Access = Public .

Local local procedure MethodName() Callable only from other procedures and triggers within the exact same object file. Completely private and encapsulated.

Exam Watchout — Event Publishers are local procedure : In Business Central standard practice, all integration and business event publisher declarations ( [IntegrationEvent] / [BusinessEvent] ) are declared as local procedure . This prevents external code from invoking the publisher procedure directly as a callable method while allowing event subscribers across the system to listen and respond to the event when fired internally.

4. Extensibility Control ( Extensible Property)

By default, objects in AL are open to extension by downstream developers ( Extensible = true ). However, architects can explicitly restrict or disable extensibility on specific objects using the Extensible = false property.

Disabling Extensibility on Tables, Pages, and Enums // Non-extensible Table: Prevents tableextension objects from adding fields or keys

  • table 50130 "Encrypted Token Store"
  • {
  • Access = Public;
  • Extensible = false;
  • DataClassification = CustomerContent;
  • fields
  • {
  • field(1; "Token Key"; Guid) { DataClassification = SystemMetadata; }
  • field(2; "Secret Payload"; Blob) { DataClassification = CustomerContent; }
  • }
  • }
  • // Non-extensible Enum: Prevents enumextension objects from adding new enum values
  • enum 50130 "Strict Processing Stage"
  • {
  • Extensible = false;
  • value(0; Initialized) { Caption = 'Initialized'; }
  • value(1; Validating) { Caption = 'Validating'; }
  • value(2; Completed) { Caption = 'Completed'; }
  • value(3; Failed) { Caption = 'Failed'; }
  • }
  • Architectural Rationale for Extensible = false

Preventing SQL Companion Table Locks: In Business Central, each table extension creates a companion SQL table joined at runtime on primary keys. High-throughput telemetry or temporary staging tables subject to hundreds of inserts per second should not allow third-party companion table joins, which could introduce database contention and lock escalation.

Security & Compliance: Sensitive setup tables (e.g., cryptographic keys, license tokens, audit logs) should prohibit external table extensions from attaching unvalidated triggers or fields.

Exhaustive State Machine Integrity: Enums used in core posting state machines that require exhaustive case statement branching should be marked Extensible = false so third-party extensions cannot inject unhandled ordinal values that corrupt transactional logic.

5. AL Code Scoping, Namespaces & Packaging Architecture

Modern AL organizes code using Namespaces , aligning Business Central development with modern software engineering standards. namespace Contoso.Logistics.Allocation;

  • using Microsoft.Sales.Document;
  • using Microsoft.Inventory.Item;
  • using Contoso.Core.Security;
  • codeunit 50140 "Stock Allocator"
  • {
  • Access = Public;
  • procedure AllocateOrder(SalesHeader: Record "Sales Header")
  • begin
  • // Implementation logic referencing imported namespaces
  • end;
  • }

Namespace Declaration: Declared at the top of every .al file before object definitions ( namespace Company.Product.Module; ).

Namespace Resolution: Prevents naming collisions when multiple ISVs create objects with identical names (e.g., two apps defining a table named "Webhook Log" ).

using Directives: Eliminates the need to fully qualify object names from standard Business Central modules or dependent extensions.