Exercise: Configure a governed multi-project AL workspace

Completed

In this exercise, you review an evidence packet from a two-project Contoso Shipment workspace. You diagnose and correct connection, identity, namespace, and analyzer configuration defects, and record the corrected values instead of downloading or running the projects.

Review the workspace

The workspace contains two AL projects: Contoso Shipment Core, which publishes shipment tracking logic that other apps can depend on, and Contoso Shipment Reports, which depends on Core and adds a shipment report. The .code-workspace file and a shared launch.json excerpt look like this:

// contoso-shipment.code-workspace
{
  "folders": [
    { "path": "ContosoShipmentCore" },
    { "path": "ContosoShipmentReports" }
  ],
  "settings": {
    "al.packageCachePath": "./.alpackages",
    "al.enableCodeAnalysis": false
  }
}
// ContosoShipmentReports/.vscode/launch.json (one configuration)
{
  "name": "Publish: Microsoft cloud sandbox",
  "type": "al",
  "request": "launch",
  "environmentType": "OnPrem",
  "server": "https://businesscentral.dynamics.com",
  "authentication": "UserPassword",
  "username": "developer@contoso.com",
  "password": "not-a-real-password",
  "tenant": "default",
  "startupObjectId": 22,
  "launchBrowser": true
}

Task 1: Correct the connection configuration

The team intends this configuration to publish to a Microsoft cloud sandbox named contoso-dev, without storing any credential in a file that's committed to source control.

Identify every property in the launch.json excerpt that's wrong for this intent, and record the corrected configuration. Your corrected version should:

  • Set environmentType to Sandbox and add environmentName set to contoso-dev, instead of the on-premises server, tenant, and authentication properties.
  • Remove username and password entirely. A cloud sandbox publish uses an interactive Microsoft Entra ID sign-in, so the file never stores a credential.
  • Keep startupObjectId and launchBrowser, which are still valid for a cloud sandbox target.

Task 2: Correct project identity and dependency configuration

Review these app.json excerpts from both projects:

// ContosoShipmentCore/app.json
{
  "id": "7a2b8f10-4c3d-4e21-9b6a-1f2c3d4e5f60",
  "name": "Contoso Shipment Core",
  "publisher": "Contoso",
  "version": "1.3.0.0",
  "application": "27.0.0.0",
  "idRanges": [{ "from": 71000, "to": 71049 }],
  "runtime": "16.0"
}
// ContosoShipmentReports/app.json
{
  "id": "c19d5e22-8a7b-4f10-9d3e-2b1a0c9f8e77",
  "name": "Contoso Shipment Reports",
  "publisher": "Contoso",
  "version": "1.1.0.0",
  "application": "27.0.0.0",
  "idRanges": [{ "from": 71050, "to": 71099 }],
  "dependencies": [
    {
      "id": "7a2b8f10-4c3d-4e21-9b6a-1f2c3d4e5f60",
      "name": "Contoso Shipment Core",
      "publisher": "Contoso",
      "version": "2.0.0.0"
    }
  ],
  "runtime": "16.0"
}

Because Core and Reports are both projects in this workspace, the dependency is a project reference. Its id, name, publisher, and version must exactly match Core's manifest. Compare the dependency entry in Reports against the version declared by Core, and answer:

  1. Can this dependency resolve as written? Why or why not?
  2. What's the smallest change that fixes the mismatch without requiring Core to release a version it hasn't reached yet?
  3. Do the two idRanges overlap? State whether this is a pass or a blocker.

The project reference can't resolve as written because Reports declares version 2.0.0.0 while Core declares version 1.3.0.0. Correct the dependency entry's version to 1.3.0.0 so the full project identity matches. The idRanges values, 71000-71049 and 71050-71099, don't overlap, so that check passes without changes.

Task 3: Resolve the namespace conflict and access boundary

Both projects declare a codeunit named Shipment Status Mgt.:

// ContosoShipmentCore: ShipmentStatusMgt.Codeunit.al
namespace Contoso.Shipping.Core;

codeunit 71000 "Shipment Status Mgt."
{
    Access = Public;

    procedure GetTrackingStatus(ShipmentNo: Code[20]): Text[50]
    begin
        exit(FormatStatus(ShipmentNo));
    end;

    local procedure FormatStatus(ShipmentNo: Code[20]): Text[50]
    begin
        exit('In transit');
    end;
}

table 71001 "Shipment Status Buffer"
{
    Access = Public;
    DataClassification = SystemMetadata;

    fields
    {
        field(1; "Shipment No."; Code[20]) { }
        field(2; "Cached Status"; Text[50]) { }
    }
}
// ContosoShipmentReports: ShipmentStatusMgt.Codeunit.al (no namespace declared)
codeunit 71050 "Shipment Status Mgt."
{
    procedure FormatForPrint(ShipmentNo: Code[20]): Text[50]
    begin
        exit(UpperCase(ShipmentNo));
    end;
}
// ContosoShipmentReports: ShipmentStatusReport.Report.al (excerpt)
report 71051 "Shipment Status Report"
{
    // Fails to compile: "GetTrackingStatus" is not a member of "Shipment Status Mgt."
    // because the reference resolves to the local, unnamespaced codeunit above.
}

Diagnose the failure, then record the corrected declarations. Your answer should identify that:

  • Reports declares its own Shipment Status Mgt. codeunit without a namespace, so an unqualified reference in the report resolves to that local codeunit instead of Core's public one, and the local codeunit has no GetTrackingStatus procedure.
  • The fix is to add a namespace declaration to the Reports codeunit, for example namespace Contoso.Shipping.Reports;, and use Core's fully qualified object name in the report. Name resolution uses the closest scope first, so a using Contoso.Shipping.Core; directive alone doesn't override the same-named object in the report's namespace.
  • The Shipment Status Buffer table in Core is internal storage that no other project should call directly. Change its Access property from Public to Internal so it's no longer part of Core's public API, while Shipment Status Mgt. and its GetTrackingStatus procedure remain Public because Reports is meant to call them.

The report can declare the Core codeunit with its fully qualified name:

namespace Contoso.Shipping.Reports;

report 71051 "Shipment Status Report"
{
    var
        CoreShipmentStatus: Codeunit Contoso.Shipping.Core."Shipment Status Mgt.";
}

Task 4: Enable governance-required analyzers and correct the ruleset

The governance brief for this workspace requires CodeCop to run on every project, with rule AA0005 enforced as at least a warning. Review the current settings and ruleset:

// workspace settings.json (excerpt, currently in effect)
{
  "al.enableCodeAnalysis": false
}
// contoso.ruleset.json
{
  "name": "Contoso Shipment ruleset",
  "description": "Rules for the Contoso Shipment workspace.",
  "rules": [
    {
      "id": "AA0001",
      "action": "Error",
      "justification": "Binary operator spacing must be consistent."
    },
    {
      "id": "AA0005",
      "action": "Hidden",
      "justification": "Suppressed temporarily during a migration."
    }
  ]
}

Compare this configuration against the brief, and record two changes:

  1. Set al.enableCodeAnalysis to true and add al.codeAnalyzers with at least ${CodeCop}, since code analysis is currently off for the whole workspace.
  2. Change the AA0005 rule's action from Hidden to Warning or Error. A Hidden action suppresses the diagnostic from the build output entirely, which contradicts a brief that requires the rule to be enforced. The temporary justification doesn't change that requirement.

Validation and success criteria

Record your findings as a short decision table with one row per defect: the file, the issue, and the corrected value. Your completed review should show that:

  • launch.json targets the contoso-dev sandbox with environmentType set to Sandbox, and contains no stored credential.
  • The dependency in ContosoShipmentReports/app.json requires a version that exactly matches the Core workspace project, and the two projects' idRanges don't overlap.
  • Both Shipment Status Mgt. codeunits have distinct namespaces, the report resolves to Core's public procedure through a fully qualified object name, and Shipment Status Buffer is Internal instead of Public.
  • Code analysis is enabled for the workspace, and AA0005 is enforced instead of hidden.

A workspace that passes all four checks builds Core before Reports in the correct dependency order, resolves every namespace reference without ambiguity, exposes only the intended public objects, and reports the governance-required analyzer findings instead of suppressing them.