mirror of
https://github.com/microsoft/BCQuality.git
synced 2026-08-06 17:36:53 +01:00
Author 7 remedial BCQuality knowledge articles plus good/bad AL samples (21 files) covering AL master-table and data-model design: - data-modeling: master No. from number series in OnInsert; use codeunit "No. Series" not obsolete NoSeriesManagement; setup table is a singleton; set Last Date Modified in OnModify and OnRename; enforce Blocked in referencing code not in the master. - style: ApplicationArea required on page controls (AS0062). - appsource: object affixes prevent collisions (AS0011). Clean-room authored from own BC knowledge; specifics verified against public sources only (learn.microsoft.com, microsoft/BCApps). Introduces two new domains (data-modeling, appsource). Co-authored-by: Jesper Schulz-Wedde <jesper.schulzwedde@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
71 lines
1.5 KiB
AL
71 lines
1.5 KiB
AL
table 50372 "Loyalty Member"
|
|
{
|
|
Caption = 'Loyalty Member';
|
|
DataClassification = CustomerContent;
|
|
|
|
fields
|
|
{
|
|
field(1; "No."; Code[20])
|
|
{
|
|
Caption = 'No.';
|
|
}
|
|
field(10; Name; Text[100])
|
|
{
|
|
Caption = 'Name';
|
|
}
|
|
field(20; Blocked; Boolean)
|
|
{
|
|
Caption = 'Blocked';
|
|
}
|
|
}
|
|
|
|
keys
|
|
{
|
|
key(PK; "No.")
|
|
{
|
|
Clustered = true;
|
|
}
|
|
}
|
|
|
|
// Anti-pattern: the block check sits in the master's own trigger. Editing a
|
|
// blocked member is rare; referencing it is constant, and references never
|
|
// fire OnModify. So this stops nothing that matters.
|
|
trigger OnModify()
|
|
begin
|
|
TestField(Blocked, false);
|
|
end;
|
|
}
|
|
|
|
table 50373 "Loyalty Point Entry"
|
|
{
|
|
Caption = 'Loyalty Point Entry';
|
|
DataClassification = CustomerContent;
|
|
|
|
fields
|
|
{
|
|
field(1; "Entry No."; Integer)
|
|
{
|
|
Caption = 'Entry No.';
|
|
AutoIncrement = true;
|
|
}
|
|
field(10; "Member No."; Code[20])
|
|
{
|
|
Caption = 'Member No.';
|
|
TableRelation = "Loyalty Member"."No.";
|
|
// No block check on the referencing side: a line can freely
|
|
// reference a blocked member, and posting proceeds unchecked.
|
|
}
|
|
field(20; Points; Integer)
|
|
{
|
|
Caption = 'Points';
|
|
}
|
|
}
|
|
|
|
keys
|
|
{
|
|
key(PK; "Entry No.")
|
|
{
|
|
Clustered = true;
|
|
}
|
|
}
|
|
}
|