bcquality/microsoft/knowledge/ui/notification-recall-needs-known-id.bad.al
Michael Dieringer cff8917ecb Address review: notification recall defect is a lost identity, not an unassigned or generated Id
- notification-recall-needs-known-id: the defect is a Recall() whose Id
  cannot be the sent one (fresh local Notification, new CreateGuid at
  recall time) while neither the sent instance nor its Id is kept. A
  retained global instance (CreateGuid once in OnOpenPage, or Id left for
  Send to assign), a generated Id saved after Send and reassigned before
  Recall, and correctly tracked per-record Ids are explicitly not findings.
  Findings require evidence that the recalled identity differs from or
  cannot recover the sent identity. Notification Lifecycle Mgt. is
  recommended for per-record tracking, not mandatory. Cites VAT Bus. Post.
  Grp. Part, Certificate, and Data Search Lines, and the lifecycle
  helper's Send-then-read-Id sequence.
- good sample: adds a page with a retained global Notification (CreateGuid
  in OnOpenPage, Send in an action, Recall in a later action and
  OnClosePage) and a pageextension that saves the Send-assigned Id and
  recalls it from a later action. Bad sample comments name the lost
  identity.
- al-ui-review: notification cue requires that evidence and lists the
  retained-instance, saved-Id, and direct per-record tracking controls as
  exclusions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 16:05:59 +02:00

21 lines
850 B
AL

pageextension 50720 "Sample Customer Card Ext" extends "Customer Card"
{
trigger OnAfterGetCurrRecord()
var
NoCreditLimitNotification: Notification;
begin
if Rec."Credit Limit (LCY)" = 0 then begin
// Send assigns an Id, but this local variable is discarded and
// the Id is not saved anywhere.
NoCreditLimitNotification.Message := NoCreditLimitMsg;
NoCreditLimitNotification.Scope := NotificationScope::LocalScope;
NoCreditLimitNotification.Send();
end else
// A fresh local variable with no Id cannot be the notification
// sent for the previous customer, so that warning is not withdrawn.
NoCreditLimitNotification.Recall();
end;
var
NoCreditLimitMsg: Label 'This customer has no credit limit.';
}