Exercise: Complete and deploy a diagnosable extension

Completed

In this exercise, you review an evidence packet for the Contoso Risk Management extension. It contains an installed version 1 manifest, an incomplete version 2 change, translation and debugging evidence, and a deployment log. You diagnose each artifact without downloading or running the project.

Task 1: Complete the missing extension behavior

Version 2 adds a risk rating enum and a calculation procedure, but the procedure is unfinished:

enum 50100 "Contoso Risk Rating"
{
    Extensible = true;
    value(0; " ") { Caption = ' '; }
    value(1; Unrated) { Caption = 'Unrated'; }
    value(2; Low) { Caption = 'Low'; }
    value(3; Medium) { Caption = 'Medium'; }
    value(4; High) { Caption = 'High'; }
}

codeunit 50102 "Risk Rating Calculator"
{
    Access = Public;

    procedure CalculateRating(DaysOverdue: Integer): Enum "Contoso Risk Rating"
    begin
        // The procedure is incomplete: apply the supplied rating rule.
        exit("Contoso Risk Rating"::Unrated);
    end;
}

The rule comment gives you everything needed to complete the procedure:

    procedure CalculateRating(DaysOverdue: Integer): Enum "Contoso Risk Rating"
    begin
        case true of
            DaysOverdue <= 0:
                exit("Contoso Risk Rating"::Low);
            DaysOverdue <= 30:
                exit("Contoso Risk Rating"::Medium);
            else
                exit("Contoso Risk Rating"::High);
        end;
    end;

Now compare the version 1 and version 2 manifests to decide the correct version number for this change:

Version 1, which is installed:

{ "id": "00001111-aaaa-2222-bbbb-3333cccc4444", "name": "Contoso Risk Management", "version": "1.2.0.0", "application": "27.0.0.0", "idRanges": [{ "from": 50100, "to": 50149 }] }

Version 2 draft:

{ "id": "00001111-aaaa-2222-bbbb-3333cccc4444", "name": "Contoso Risk Management", "version": "1.2.0.0", "application": "27.0.0.0", "idRanges": [{ "from": 50100, "to": 50149 }] }

The draft still declares 1.2.0.0, unchanged from version 1. Because this change adds a new enum and a new public procedure without changing or removing anything version 1 already exposed, it's an additive change. Under Contoso's documented version policy, raise version to 1.3.0.0. The platform doesn't assign semantic meaning to the four version parts, so this choice depends on the team's stated policy.

A local build has no compiler errors. A comparison between the generated source XLIFF file and the French target file reports two missing translations, which you resolve in the next task. The object IDs used, 50100 and 50102, both fall inside the declared idRanges.

Task 2: Update the translation content

The build regenerates the source .xlf file with a new RatingUpdatedMsg label and the enum's caption. The team's French target file, last updated for version 1, is missing both:

<!-- ContosoRiskManagement.fr-FR.xlf (current, incomplete) -->
<trans-unit id="Enum 50100 - Value 2" size-unit="char" translate="yes" xml:space="preserve">
  <source>Low</source>
  <target>Faible</target>
</trans-unit>
<trans-unit id="Enum 50100 - Value 3" size-unit="char" translate="yes" xml:space="preserve">
  <source>Medium</source>
  <target>Moyen</target>
</trans-unit>
<trans-unit id="Enum 50100 - Value 4" size-unit="char" translate="yes" xml:space="preserve">
  <source>High</source>
  <target>Élevé</target>
</trans-unit>

The IDs in this evidence packet represent IDs copied unchanged from the generated source file. Two units are missing from the target file: the Unrated enum caption and the new RatingUpdatedMsg label. Add both:

<trans-unit id="Enum 50100 - Value 1" size-unit="char" translate="yes" xml:space="preserve">
  <source>Unrated</source>
  <target>Non évalué</target>
</trans-unit>
<trans-unit id="Codeunit 50102 - Method 50103 - NamedType 0 - Property 2879900210" size-unit="char" translate="yes" xml:space="preserve">
  <source>Risk rating for customer %1 was updated.</source>
  <target>La cote de risque du client %1 a été mise à jour.</target>
  <note from="Developer" annotates="general" priority="2">%1 = Customer number</note>
</trans-unit>

The label declares Comment = '%1 = Customer number' in AL, which the generated <note> element carries into the target file so the translation you added preserves that context. The label isn't Locked, so it's expected to appear in the target file; a locked label, such as a fixed error code, would only appear if the extension's manifest set GenerateLockedTranslations, which this manifest doesn't.

Task 3: Choose and interpret the right debugging evidence

Testing reports two symptoms for version 2.

Symptom A: When a developer manually opens the Customer Card and edits a customer with 45 days overdue, the risk rating field shows blank instead of High. The developer can reproduce this on demand in their own sandbox session.

Because the developer controls the trigger and can restart the client freely, interactive debugging is the right choice here, with a breakpoint on CalculateRating. The evidence packet includes the call stack captured at that breakpoint:

CalculateRating(DaysOverdue: 45) — Codeunit 50102 line 6
  OnValidate(Field "Days Overdue") — Table 50101 line 14
    OnModify(Rec) — Page 50100 line 22

Stepping through shows DaysOverdue arrives as 45, but the case statement's else branch was never reached before this fix; the breakpoint confirms the corrected logic in Task 1 now exits High as expected.

Symptom B: A nightly job queue entry that recalculates ratings for all customers occasionally times out, only in production, and only against a data set that's hard to reproduce in a sandbox. Restarting the session to attach a debugger isn't safe, and the delay before the job runs makes interactive debugging impractical.

This symptom needs snapshot debugging: production, delayed, and not safe to interrupt. The packet includes the armed configuration and the recorded evidence. Initialize the snapshot shortly before the scheduled run so the next matching background session starts within the 30-minute attachment window:

{
  "name": "Contoso production (snapshot)",
  "type": "al",
  "request": "snapshotInitialize",
  "environmentType": "Production",
  "environmentName": "contoso-prod",
  "breakOnNext": "Background",
  "userId": "00001111-aaaa-2222-bbbb-3333cccc4444",
  "executionContext": "DebugAndProfile"
}
Snappoint hit: CalculateRating(DaysOverdue: 812) — Codeunit 50102 line 3
  Variable DaysOverdue: 812
Snappoint hit: CalculateRating(DaysOverdue: -4) — Codeunit 50102 line 3
  Variable DaysOverdue: -4

The recording shows that -4 resolves to Low through the first condition. The timeout isn't in this procedure, so the calling loop needs a separate investigation. The snapshot still rules out CalculateRating as the cause.

Task 4: Evaluate the deployment and make an acceptance decision

The deployment log for version 1's original install shows the expected order:

Publish-NAVApp: Contoso Risk Management 1.2.0.0 — staged, symbols validated.
Sync-NAVApp: Contoso Risk Management 1.2.0.0 — schema synchronized, 0 rows affected.
Install-NAVApp: Contoso Risk Management 1.2.0.0 — installed for tenant contoso-dev.

For version 2, the log shows an attempted publish before the fix from Task 1 was applied, followed by the corrected sequence after the fix:

Publish-NAVApp: Contoso Risk Management 1.3.0.0 — staged, symbols validated.
Sync-NAVApp: Contoso Risk Management 1.3.0.0 — schema synchronized, 1 table extension field added, 0 rows lost.
Start-NAVAppDataUpgrade: Contoso Risk Management 1.3.0.0 — upgrade completed for tenant contoso-dev.

Because version 2 only adds a new enum and a new field, the default schemaUpdateMode of Synchronize is the correct choice: it preserves every existing customer record while adding the new field with a blank default value. Recreate would have dropped and rebuilt the table data unnecessarily, and ForceSync is reserved for development and test scenarios, not this tenant's data.

The upgrade codeunit populates the new field for existing customers:

codeunit 50110 "Contoso Risk Mgt Upgrade"
{
    Subtype = Upgrade;

    trigger OnUpgradePerCompany()
    var
        Customer: Record Customer;
    begin
        if Customer.FindSet(true) then
            repeat
                if Customer."Contoso Risk Rating" = Customer."Contoso Risk Rating"::" " then
                    Customer.Validate("Contoso Risk Rating", Customer."Contoso Risk Rating"::Unrated);
                Customer.Modify(true);
            until Customer.Next() = 0;
    end;
}

Contoso's acceptance checklist requires an explicit validation of the migration result. The packet is missing an OnValidateUpgradePerCompany trigger, so add one before accepting the upgrade:

    trigger OnValidateUpgradePerCompany()
    var
        Customer: Record Customer;
    begin
        Customer.SetRange("Contoso Risk Rating", Customer."Contoso Risk Rating"::" ");
        if not Customer.IsEmpty() then
            Error(UpgradeIncompleteErr);
    end;

    var
        UpgradeIncompleteErr: Label 'One or more customers still have a blank risk rating after upgrade.';

Validation and acceptance decision

In a live sandbox, you'd confirm these same conclusions by building the corrected code, publishing version 1, entering test customer data, publishing version 2, and observing the actual synchronize and upgrade output. Based on the evidence packet alone, record your acceptance decision:

  • Accept version 2 for deployment once the OnValidateUpgradePerCompany trigger is added, because the code fix, version number, translation file, and Synchronize schema mode are all now correct.
  • Do not accept it as originally packaged, because an upgrade package that doesn't meet the documented validation requirement lacks evidence that every existing record was migrated.

Success criteria: the corrected procedure returns the documented rating for every input range, the French target file has no missing translation units relative to the new source file, the debugging mode chosen for each symptom matches its access and timing constraints, and the version 2 deployment plan preserves existing customer data while verifying the upgrade's completeness before accepting it.