Skip to content

Commit 4995323

Browse files
fix(devenv-extension-example): add namespaces, DataClassification, Access=Internal, fix semicolon
All complete AL object definitions now include namespace Contoso.Rewards and using directives, matching real production patterns from microsoft/ALAppExtensions. Objects updated: - table 50100 Reward: namespace + DataClassification = CustomerContent on all fields (was ToBeClassified on field 1 Reward ID, missing on fields 2-3) - page 50101 Reward Card: namespace - page 50102 Reward List (both occurrences): namespace - tableextension 50103 Customer Ext: namespace + using Microsoft.Sales.Customer + DataClassification = CustomerContent on Reward ID field + fixed missing semicolon on Error() call + fixed trigger OnValidate(); -> OnValidate() (no trailing semicolon) - pageextension 50104 Customer Card Ext: namespace + using Microsoft.Sales.Customer - codeunit 50105 RewardsInstallCode: namespace + Access = Internal + fixed trigger OnInstallAppPerCompany(); -> OnInstallAppPerCompany() - codeunit 50106 RewardsUpgradeCode: namespace + Access = Internal + fixed trigger OnUpgradePerCompany(); -> OnUpgradePerCompany() Source patterns from: ALAppExtensions/Apps/W1/ReviewGLEntries/app/src/tables/GLEntryReviewSetup.Table.al ALAppExtensions/Apps/W1/LatePaymentPredictor/app/src/LatePaymentInstall.Codeunit.al
1 parent 9148534 commit 4995323

1 file changed

Lines changed: 34 additions & 6 deletions

File tree

dev-itpro/developer/devenv-extension-example.md

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,27 @@ The following code adds a new table **50100 Reward** for storing the reward leve
4747
> Type `ttable` followed by the <kbd>Tab</kbd> key. This snippet will create a basic layout for a table object.
4848
4949
```AL
50+
namespace Contoso.Rewards;
51+
5052
table 50100 Reward
5153
{
52-
DataClassification = ToBeClassified;
54+
DataClassification = CustomerContent;
5355
5456
fields
5557
{
5658
// The "Reward ID" field represents the unique identifier
5759
// of the reward and can contain up to 30 Code characters.
5860
field(1;"Reward ID";Code[30])
5961
{
60-
DataClassification = ToBeClassified;
62+
DataClassification = CustomerContent;
6163
}
6264
6365
// The "Description" field can contain a string
6466
// with up to 250 characters.
6567
field(2;Description;Text[250])
6668
{
69+
DataClassification = CustomerContent;
70+
6771
// This property specified that
6872
// this field cannot be left empty.
6973
NotBlank = true;
@@ -74,6 +78,8 @@ table 50100 Reward
7478
// be applied for this reward.
7579
field(3;"Discount Percentage";Decimal)
7680
{
81+
DataClassification = CustomerContent;
82+
7783
// The "MinValue" property sets the minimum value for the "Discount Percentage"
7884
// field.
7985
MinValue = 0;
@@ -110,6 +116,8 @@ The following code adds a new page **50101 Reward Card** for viewing and editing
110116
> Use the snippet `tpage, Page` to create the basic structure for the page object.
111117
112118
```AL
119+
namespace Contoso.Rewards;
120+
113121
page 50101 "Reward Card"
114122
{
115123
// The page will be of type "Card" and will render as a card.
@@ -160,6 +168,8 @@ The following code adds the **50102 Reward List** page that enables users to vie
160168
> Use the snippet `tpage, Page of type list` to create the basic structure for the page object.
161169
162170
```AL
171+
namespace Contoso.Rewards;
172+
163173
page 50102 "Reward List"
164174
{
165175
// Specify that this page will be a list page.
@@ -256,27 +266,33 @@ The following code creates a table extension for the **Customer** table and adds
256266
> Use the snippet `ttableext` to create a basic structure for the table extension object.
257267
258268
```AL
269+
namespace Contoso.Rewards;
270+
271+
using Microsoft.Sales.Customer;
272+
259273
tableextension 50103 "Customer Ext" extends Customer
260274
{
261275
fields
262276
{
263277
field(50100;"Reward ID";Code[30])
264278
{
279+
DataClassification = CustomerContent;
280+
265281
// Set links to the "Reward ID" from the Reward table.
266282
TableRelation = Reward."Reward ID";
267283
268284
// Set whether to validate a table relationship.
269285
ValidateTableRelation = true;
270286
271287
// "OnValidate" trigger executes when data is entered in a field.
272-
trigger OnValidate();
288+
trigger OnValidate()
273289
begin
274290
275291
// If the "Reward ID" changed and the new record is blocked, an error is thrown.
276292
if (Rec."Reward ID" <> xRec."Reward ID") and
277293
(Rec.Blocked <> Blocked::" ") then
278294
begin
279-
Error('Cannot update the rewards status of a blocked customer.')
295+
Error('Cannot update the rewards status of a blocked customer.');
280296
end;
281297
end;
282298
}
@@ -295,6 +311,10 @@ A page extension object can be used to add new functionality to pages that are p
295311
> Use the shortcuts `tpageext` to create the basic structure for the page extension object.
296312
297313
```AL
314+
namespace Contoso.Rewards;
315+
316+
using Microsoft.Sales.Customer;
317+
298318
pageextension 50104 "Customer Card Ext" extends "Customer Card"
299319
{
300320
layout
@@ -358,6 +378,8 @@ Next, you set the [ContextSensitiveHelpPage property](properties/devenv-contexts
358378
The following example shows the properties for the **Reward List** page after you've specified the context-sensitive help page.
359379

360380
```AL
381+
namespace Contoso.Rewards;
382+
361383
page 50102 "Reward List"
362384
{
363385
// Specify that this page will be a list page.
@@ -437,13 +459,16 @@ In this example, the following install codeunit initializes the **Reward** table
437459
> Use the shortcuts `tcodeunit` to create the basic structure for the codeunit.
438460
439461
```AL
462+
namespace Contoso.Rewards;
463+
440464
codeunit 50105 RewardsInstallCode
441465
{
442466
// Set the codeunit to be an install codeunit.
443467
Subtype = Install;
468+
Access = Internal;
444469
445470
// This trigger includes code for company-related operations.
446-
trigger OnInstallAppPerCompany();
471+
trigger OnInstallAppPerCompany()
447472
var
448473
Reward : Record Reward;
449474
begin
@@ -487,15 +512,18 @@ When you upgrade an extension to a newer version, any modifications, which are r
487512
> Remember to increase the `version` number of the extension in the app.json file.
488513
489514
```AL
515+
namespace Contoso.Rewards;
516+
490517
codeunit 50106 RewardsUpgradeCode
491518
{
492519
// An upgrade codeunit includes AL methods for synchronizing changes to a table definition
493520
// in an application with the business data table in SQL Server and migrating existing
494521
// data.
495522
Subtype = Upgrade;
523+
Access = Internal;
496524
497525
// "OnUpgradePerCompany" trigger is used to perform the actual upgrade.
498-
trigger OnUpgradePerCompany();
526+
trigger OnUpgradePerCompany()
499527
var
500528
Reward : Record Reward;
501529

0 commit comments

Comments
 (0)