MB-820 Cheatsheet
Microsoft Dynamics 365 Business Central Developer
Download free PDFDescribe Business Central (10–15%)
Deployment and data boundaries
- **Business Central online** is a Microsoft-managed service. **On-premises** runs on infrastructure you manage, including the server tier and SQL database. Production and sandbox environments serve different operational purposes.
- In a **single-tenant** deployment, application and business data can share one database. **Multitenancy** separates shared application metadata from tenant business databases; a tenant can contain multiple companies.
- A **company** partitions company-specific business data. It is not a separate tenant or environment. Select separate environments when localization, administration or isolation requirements need a stronger boundary.
- The **web client** presents pages, the **Business Central Server** executes AL business logic, and **SQL Server** persists data. Online extensions must respect the service's restrictions on filesystem and server access.
Apps and application layers
- The **System Application** supplies reusable platform-facing capabilities; the **Base Application** supplies ERP business functionality. Build extensions against published symbols and dependencies rather than modifying base objects.
- An **add-on app** extends Business Central using AL. A **Connect app** integrates an external service through APIs and can use the external platform's language. A **per-tenant extension (PTE)** serves a specific customer.
- **AppSource** apps require validation, supported object IDs and a maintained upgrade path. The **50000–99999** custom range is used for customer customizations; AppSource apps use a Microsoft-assigned range.
- **Power Apps**, **Power Automate** and **Power BI** consume supported connectors or APIs. Check deployment support for each integration; a feature available online is not automatically available on-premises.
Install, develop, and deploy for Business Central (10–15%)
Project and environment configuration
- Install the **AL Language** extension in Visual Studio Code, create an AL project and **download symbols**. Missing target objects often indicate missing symbols, dependencies or a mismatched target environment.
- **app.json** describes app identity, version, publisher, dependencies, ID ranges, application/platform compatibility and **runtime**. Target a runtime supported by the oldest intended server and avoid unsupported language features.
- **launch.json** defines the target server or online environment, authentication, startup object and debug/publish options. On-premises symbol access needs the correct **serverInstance**, developer-services **port** and authentication mode.
- **settings.json** controls editor/compiler behavior such as analyzers and rule sets. Workspace settings apply to the project; user settings affect the developer's wider editor environment.
- **BcContainerHelper** creates local development containers from selected Business Central artifacts. Use **Get-BcArtifactUrl** to select the intended release, country and artifact type; install or import the test toolkit for automated tests.
Publishing and schema changes
- **Publish** makes a package available; **synchronize** aligns schema; **install** enables the app for a tenant; **data upgrade** migrates existing data to a new app version. These are distinct lifecycle operations.
- For sandbox publishing, **Synchronize** preserves compatible data, **Recreate** recreates extension tables and loses their data, and **ForceSync** permits destructive schema changes. Keep destructive development modes away from production data.
- Use managed **PTE/AppSource deployment** for maintained customer solutions. Development-published extensions are temporary development artifacts; test compatibility before service upgrades and configure administrative notifications.
- **resourceExposurePolicy** in app.json controls **allowDebugging**, **allowDownloadingSource** and source inclusion in symbols. Debug access and permission to download source are separate choices.
Install, upgrade and retire safely
- An **Install** codeunit uses **OnInstallAppPerCompany** or **OnInstallAppPerDatabase** for initialization. An **Upgrade** codeunit migrates existing installations; scope company data separately from database-wide work.
- **NavApp.GetCurrentModuleInfo** returns module metadata. During an upgrade, **AppVersion** identifies the package being installed and **DataVersion** identifies the version to which data was previously upgraded. Use version checks or upgrade tags to avoid repeating migrations.
- Retire fields with **ObsoleteState = Pending**, an **ObsoleteReason** and an **ObsoleteTag**, allowing consumers to migrate before **Removed**. Procedures use the **Obsolete** attribute; do not delete a public dependency without a replacement path.
- **DataTransfer** moves data in bulk during supported lifecycle code. Configure **SetTables**, field mappings and filters; **CopyRows** inserts matching rows into another table, while **CopyFields** updates mapped fields using joins.
- Bulk **DataTransfer** bypasses row triggers and events. Plan defaults, primary-key conflicts and required transformations explicitly; use record-by-record AL when each row needs business validation.
Develop by using AL objects (35–40%)
Tables and business integrity
- Use **Code** for normalized identifiers and alphanumeric document numbers, **Text** for descriptions, **Date** for a calendar date, **DateTime** for an instant, **Decimal** for quantities or amounts, and **Guid/SystemId** for stable identity.
- A document commonly has **header and line tables** linked by document type/number; posted history uses separate historical tables. A **setup table** holds configuration such as permitted dates and number-series codes.
- **TableRelation** defines lookups and related-record constraints. Filter the relation with **FIELD** values for dependent lookups, such as receipts belonging to the selected vendor. **ValidateTableRelation** controls relation validation.
- Put shared business rules in **table triggers** or reusable codeunits. **OnInsert** can initialize a date from **WorkDate()**; **InitValue** supplies a default status. A status field's **OnValidate** can stamp a closing date.
- **WorkDate()** is the session's business date; **Today()** is the current calendar date. Use the one required by the process. **AutoIncrement** numbers entries; **No. Series** manages configurable business document numbering.
- Use a **No. Series** code from setup, validate the configuration and request the next number when inserting an unnumbered document. Let the standard number-series API manage sequencing; do not construct document numbers with MAX + 1.
- Deletion rules need explicit logic: filter dependent rows, check whether deletion is allowed, and delete them through the required triggers. A **TableRelation** does not itself implement cascading deletion.
Extension points and modules
- **tableextension** adds fields and supported modifications to extensible tables; **pageextension** adapts existing page controls and actions. Only properties supported for extension modification can be changed.
- **reportextension** adds supported dataset, request-page and layout changes. **enumextension** adds values to an extensible enum. Codeunits and queries are composed or integrated through procedures/events rather than a codeunitextension or queryextension.
- Use **codeunits** to isolate responsibilities. Expose a small public facade and keep implementation procedures **local** or objects **Internal** where appropriate. Explicit dependencies allow one app to consume another app's supported contract.
- A **protected var** on an extensible object permits extension objects to access that state. An ordinary global variable is not automatically accessible from another extension; prefer procedures when callers should not manipulate state directly.
- Publish **integration events** and subscribe with **EventSubscriber** to add behavior without editing base code. Choose the event's timing and parameters carefully; posting validation must cover shipping-only paths and respect **PreviewMode**.
Pages, Role Centers and views
- **Card** edits one entity, **List** browses records, **Document** combines a header and line part, **ListPart/CardPart** embeds related information, and **NavigatePage** supports a step-by-step wizard.
- A wizard uses step groups with controlled **Visible** expressions and Next/Back actions. Register appropriate setup experiences with **Assisted Setup**; a **RoleCenter** is the role's navigation and activity workspace.
- On Role Centers, **area(embedding)** supplies navigation-bar links, **area(sections)** supplies navigation menus, and creation/reporting/processing areas group actions. Activity parts and **cuegroup** controls summarize work.
- Use **SubPageLink** to relate a part to the current parent. Use **RunObject**, **RunPageLink** and **RunPageMode** for action navigation; use **SourceTableView** for an initial source-table filter and sorting.
- A **pageextension** can **modify** a field's visibility or use **movefirst/moveafter** to reorder controls. A **views** section defines named list filters and sorting; **SharedLayout = false** allows a view-specific layout.
- **Caption** names a control; **ToolTip** explains it; **InstructionalText** can prompt for empty-field input. **Style = Strong** with a Boolean **StyleExpr** can emphasize an amount only when its record is posted.
- **Profiles** associate roles with Role Centers and page customizations. Personalization and hidden controls tailor presentation; authorization still depends on permissions. Use the supported **rich text** control configuration for formatted comments.
Queries and aggregation
- A **query** defines dataitems and columns. Link a lower dataitem to its parent with **DataItemLink** and select **SqlJoinType**: **LeftOuterJoin** retains unmatched parent rows; **InnerJoin** returns matching combinations only.
- A join can multiply rows when several child records match. Check the complete relationship and cardinality before treating a larger result as a calculation problem; use all fields needed to identify the parent.
- Set a column's **Method = Sum** for totals; nonaggregated columns determine the grouping. **OrderBy = descending(...)** orders results and **TopNumberOfRows** limits the result set.
- For a query variable, set filters, call **Open()**, iterate with **Read()**, consume column values and **Close()**. Use **SaveAsCsv** or **SaveAsXml** for supported exports; a filename extension alone does not select a format.
Report datasets and triggers
- A report separates the **dataset**, **request page** and **layout**. Link nested dataitems with **DataItemLink**; missing or incomplete links can return every line for each header.
- **OnInitReport** runs during report initialization. The request page collects options; **OnPreReport** can validate the resulting inputs before processing. **OnPreDataItem** applies final dataitem filters.
- **OnAfterGetRecord** runs for each retrieved record, **OnPostDataItem** follows completion of that dataitem, and **OnPostReport** follows report processing. Place calculations at the scope where their inputs and accumulators are valid.
- **CurrReport.Skip()** omits the current record from the dataset, **Break()** ends a dataitem's iteration, and **Quit()** terminates the report. Choose the operation matching the required scope.
- Use a **reportextension** when extension points suffice. When a replacement report is required, use the supported **ReportManagement.OnAfterSubstituteReport** event to substitute its report ID.
Request pages, layouts and XMLports
- **RequestFilterFields** promotes common filter fields. **DataItemTableView** fixes sorting/filter constraints and can suppress a dataitem's request-page FastTab when no request filter fields are exposed.
- **SaveValues = true** enables saved request settings. For repeated previews without closing the request page, enable both **SaveValues** and **AllowScheduling**. Validate selected dates and user-based filters before running the dataset.
- **RDLC**, **Word** and **Excel** layouts serve different output needs. An **Excel layout** uses a workbook template over the report dataset; arrange posted/unposted outputs through the workbook design when separate worksheets are required.
- An **XMLport** imports or exports structured data. **Format = Xml** produces XML, **VariableText** supports delimited files such as CSV, and **FixedText** uses fixed widths. Configure delimiters, separators and encoding explicitly.
- **Direction = Export** prevents imports; **Both** supports either direction. Link nested tableelements with **LinkTable/LinkFields** or explicit filtering. **OnPreXmlPort** prepares execution and **OnPostXmlPort** runs after processing.
Permissions and entitlements
- A **permission set** groups object permissions. **Assignable = true** makes it available for user assignment; nonassignable sets are composition building blocks. Grant **tabledata** access separately from permission to execute a page, report or codeunit.
- **R/I/M/D/X** identify read, insert, modify, delete and execute. Direct access and indirect access differ: a user with **indirect** data permission needs an authorized object with the appropriate **Permissions** property to perform the operation.
- **IncludedPermissionSets** composes permissions; **ExcludedPermissionSets** subtracts permissions within that composition. Inspect the user's **Effective Permissions** across all assignments; exclusion in one set is not a global deny against another grant.
- A **permissionsetextension** extends an existing set. Use narrow task-specific grants for posting and reporting; changing a Role Center or hiding a page does not secure its underlying data.
- **InherentPermissions** can authorize a narrow method scope within its own extension. Reserve inherent grants for suitable internal tasks; business-data access that administrators must control belongs in managed permissions.
- An **entitlement** defines licensed access and a permission set defines assigned access. **PerUserServicePlan** maps an AppSource entitlement to a service plan; licensing and role assignment must both support the operation.
Develop by using AL (15–20%)
Records, filters and transactions
- **Get** retrieves by primary key; **FindFirst/FindLast** locate a record in the current view; **FindSet** supports iteration with **Next()**. Use **IsEmpty** when only existence matters and filter both document type and number for document lines.
- **SetRange** applies an exact value or interval; **SetFilter** accepts expressions. **B*** means starts with B, **<>S*** excludes that prefix, **|** means OR and **&** means AND. Use placeholders instead of concatenating user-entered filter text.
- **Reset()** clears filters and restores the default record view. **SetCurrentKey** requests a sorting key. **CalcFields** calculates FlowFields; **SetAutoCalcFields** can request needed calculations during retrieval.
- **Validate(Field, Value)** invokes field validation; direct assignment does not. **Insert(true)**, **Modify(true)** and **Delete(true)** request table triggers; make trigger behavior explicit where business rules depend on it.
- **Error** stops execution and rolls back the current uncommitted transaction. **Commit** splits transaction boundaries, so later errors cannot undo earlier commits. Avoid commits inside reusable posting validation.
- **Round(Value, 0.0001, '>')** rounds with upward direction at four decimal places. The precision is a rounding increment, not a count of decimal places; formatting a number does not change its stored value.
Collections, streams and localization
- **List** and **Dictionary** are reference types: assignment can share the same collection. A **var** parameter permits replacement of the caller's variable; a non-var reference-type parameter can still mutate shared contents.
- **InStream** reads and **OutStream** writes. Use the **Temp Blob** codeunit to buffer data, create the needed streams, and **DownloadFromStream** to send a file to the client in online-compatible code.
- **Media/MediaSet** store managed media references. Export the selected media to an **OutStream**, then create an **InStream** for download. A BLOB field needs its content calculated before streaming when required.
- Use **labels/captions** with **XLIFF** translation files for maintained multilingual apps. **Locked = true** marks text that must not be translated. **Comment** provides translator or developer context without becoming the user caption.
- **CaptionML** represents inline multilingual captions in older patterns. Prefer a single translatable caption and language resources for new development; avoid duplicating the same caption separately on every page.
- Use **DataClassification** for table fields and protect sensitive values with **SecretText** where supported. Avoid hard-coded regional date formats; represent dates as Date values and let supported formatting handle presentation.
Work with development tools (10–15%)
Analysis and automated tests
- Enable **al.enableCodeAnalysis** and select analyzers in **al.codeAnalyzers**. **CodeCop** checks AL practices, **UICop** checks UI rules, **AppSourceCop** checks AppSource compatibility, and **PerTenantExtensionCop** targets PTE requirements.
- Set **al.ruleSetPath** in workspace settings to a local rule set. A rule's **id** and **action** can change its diagnostic severity for that app; suppressing a warning does not fix the underlying compatibility issue.
- A test codeunit uses **Subtype = Test** and **[Test]** methods. Use deterministic setup, execute the behavior and assert persisted results; install the **Test Toolkit** and required test libraries in the test environment.
- Use **TransactionModel = AutoRollback** for test methods that must revert database changes. A **TestRunner** can define isolation between tests; design tests around actual commit and transaction behavior.
- Register UI handlers with **HandlerFunctions**. **MessageHandler**, **ConfirmHandler** and **StrMenuHandler** simulate the matching UI; an unhandled message or confirm fails an unattended test.
- Use **TestPage** to open pages, set fields and invoke actions such as approval. Assertions check outcomes; handlers supply dialog choices. Run tests in CI against a clean, compatible application and test-library set.
Debugging and telemetry
- Use breakpoints, conditional breakpoints, call stacks and watches to inspect the execution path. For report errors, break where the column is assigned and inspect record filters, accumulator resets and trigger timing.
- **Snapshot debugging** captures an eligible session for later inspection. Verify environment, user **GUID**, session targeting, **breakOnNext** client type and source/debug permissions when capture does not start.
- Configure environment telemetry in the **Business Central admin center** and extension telemetry through **applicationInsightsConnectionString** in app.json. Confirm data reaches the intended **Application Insights** resource.
- **Session.LogMessage** emits custom telemetry with an event ID, verbosity, classification, dimensions and scope. **TelemetryScope::ExtensionPublisher** targets publisher telemetry; **All** can also expose the event to environment telemetry.
- Use **KQL** over telemetry: filter a recent interval with **timestamp > ago(7d)**, then filter event IDs and **customDimensions** for the relevant environment, endpoint or operation. Summarize counts and durations to identify patterns.
- Use incoming web-service telemetry to identify **SOAP** consumers and failed integrations. Correlate **job queue lifecycle** events across enqueue, start, success and failure to distinguish scheduling, execution and repeated retry problems.
Integrate Business Central with other applications (10–15%)
API contracts and read scale
- A custom **PageType = API** page defines **APIPublisher**, **APIGroup**, **APIVersion**, **EntityName** and **EntitySetName** over its source table. Use **ODataKeyFields = SystemId** for a stable entity key.
- Custom API routes follow **/api/{publisher}/{group}/{version}/companies({companyId})/{entitySet}** under the environment's service root. Consumers need the tenant/environment, company GUID and declared API names, not the page's numeric object ID.
- API pages are exposed by their API metadata and do not require publication on the **Web Services** page. That page publishes supported conventional OData/SOAP objects; API queries use **QueryType = API** for read-only datasets.
- **GET** retrieves, **POST** creates or invokes an action, **PATCH** changes selected fields and **DELETE** removes an entity. Use the required **ETag/If-Match** for optimistic concurrency and OAuth access tokens for online authentication.
- An OData **bound action** is invoked with **POST** on an entity's action route, such as **.../entities({id})/Microsoft.NAV.copy**. Match the exposed namespace and action name; it is not a PATCH to a field.
- **DataAccessIntent = ReadOnly** permits supported read operations to use a read replica. For a GET-only API page, also set **InsertAllowed**, **ModifyAllowed** and **DeleteAllowed** to false; read intent alone is not the full API access policy.
- Read replicas reduce transactional load but can lag the primary. Choose them for reporting and analytics when that freshness trade-off is acceptable; real-time operational reads may need the primary database.
HTTP, JSON and background work
- Use **HttpClient** for outbound requests, **HttpRequestMessage** for method/URI/content and **HttpResponseMessage** for status/body. Enable outbound HTTP requests for the extension and check both transport success and **IsSuccessStatusCode**.
- For a JSON POST, write the payload into **HttpContent** and set its **Content-Type** to **application/json** through content headers. Authentication headers belong on the request or client, not in the JSON body.
- When an external service requires **Basic authentication**, send a Base64-encoded username:password value in the Authorization header over HTTPS. Base64 is encoding, so secure storage and protected transport remain necessary.
- Use **HttpClient.AddCertificate** for supported client-certificate authentication and **SecretText** for sensitive certificate/password values. Keep credentials out of logs, telemetry and plain debug variables.
- Parse with **JsonObject/JsonArray.ReadFrom**, retrieve members into **JsonToken**, and use **AsObject**, **AsArray** or **AsValue** according to token type. Iterate every array element and check missing/null properties before conversion.
- A **job queue** runs a codeunit in a background session, normally through **OnRun**. Keep the same business process callable from a page action, avoid interactive dialogs in unattended execution, and make retries safe from duplicate processing.
- Use modern **APIs/OData** for integrations and monitor existing SOAP usage before migration. Connectors and **business events** support Power Platform workflows; choose polling, scheduled jobs or events according to latency and reliability needs.