-
Notifications
You must be signed in to change notification settings - Fork 0
/
Table 50120 Reward.al
136 lines (119 loc) · 3.23 KB
/
Table 50120 Reward.al
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
table 50120 Reward
{
DataClassification = ToBeClassified;
fields
{
field(1; "Reward ID"; Code[30])
{
DataClassification = ToBeClassified;
}
field(2; Description; Text[250])
{
DataClassification = ToBeClassified;
}
field(3; "Discount Percentage"; Decimal)
{
DataClassification = ToBeClassified;
MinValue = 0;
MaxValue = 100;
DecimalPlaces = 2;
}
field(4; "Minimum Purchase"; Decimal)
{
MinValue = 0;
DecimalPlaces = 2;
}
field(5; "Last Modified Date"; Date)
{
Editable = false;
}
}
keys
{
key(PK; "Reward ID")
{
Clustered = true;
}
}
var
myInt: Integer;
trigger OnInsert()
begin
setLastModifiedDate();
end;
trigger OnModify()
begin
setLastModifiedDate();
end;
trigger OnDelete()
begin
end;
trigger OnRename()
begin
setLastModifiedDate();
end;
local procedure setLastModifiedDate()
begin
Rec."Last Modified Date" := Today;
end;
}
/*
codeunit 50125 RewardsInstallCode
{
// Set the codeunit to be an install codeunit.
Subtype = Install;
// This trigger includes code for company-related operations.
trigger OnInstallAppPerCompany();
var
Reward: Record Reward;
begin
// If the "Reward" table is empty, insert the default rewards.
if Reward.IsEmpty() then begin
InsertDefaultRewards();
end;
end;
// Insert the GOLD, SILVER, BRONZE reward levels
procedure InsertDefaultRewards();
begin
InsertRewardLevel('GOLD', 'Gold Level', 20);
InsertRewardLevel('SILVER', 'Silver Level', 10);
InsertRewardLevel('BRONZE', 'Bronze Level', 5);
end;
// Create and insert a reward level in the "Reward" table.
procedure InsertRewardLevel(ID: Code[30]; Description: Text[250]; Discount: Decimal);
var
Reward: Record Reward;
begin
Reward.Init();
Reward."Reward ID" := ID;
Reward.Description := Description;
Reward."Discount Percentage" := Discount;
Reward.Insert();
end;
}
codeunit 50126 RewardsUpgradeCode
{
// An upgrade codeunit includes AL methods for synchronizing changes to a table definition
// in an application with the business data table in SQL Server and migrating existing
// data.
Subtype = Upgrade;
// "OnUpgradePerCompany" trigger is used to perform the actual upgrade.
trigger OnUpgradePerCompany();
var
Reward: Record Reward;
// "ModuleInfo" is the current executing module.
Module: ModuleInfo;
begin
// Get information about the current module.
NavApp.GetCurrentModuleInfo(Module);
// If the code needs to be upgraded, the BRONZE reward level will be changed into the
// ALUMINUM reward level.
if Module.DataVersion.Major = 1 then begin
Reward.Get('BRONZE');
Reward.Rename('ALUMINUM');
Reward.Description := 'Aluminum Level';
Reward.Modify();
end;
end;
}
*/