bcquality/microsoft/knowledge/data-modeling/master-table-no-from-number-series-in-oninsert.good.al
Jesper Schulz-Wedde 766046b85d
Add data-modeling and appsource knowledge articles (MICROSOFT layer) (#65)
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>
2026-07-13 10:35:31 +02:00

45 lines
970 B
AL

table 50360 "Loyalty Member"
{
Caption = 'Loyalty Member';
DataClassification = CustomerContent;
fields
{
field(1; "No."; Code[20])
{
Caption = 'No.';
NotBlank = true;
}
field(2; "No. Series"; Code[20])
{
Caption = 'No. Series';
Editable = false;
TableRelation = "No. Series";
}
field(10; Name; Text[100])
{
Caption = 'Name';
}
}
keys
{
key(PK; "No.")
{
Clustered = true;
}
}
trigger OnInsert()
var
LoyaltySetup: Record "Loyalty Setup";
NoSeries: Codeunit "No. Series";
begin
if "No." = '' then begin
LoyaltySetup.Get();
LoyaltySetup.TestField("Member Nos.");
"No. Series" := LoyaltySetup."Member Nos.";
"No." := NoSeries.GetNextNo("No. Series");
end;
end;
}