-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTableext 50123 Customer Extend.al
42 lines (37 loc) · 1.26 KB
/
Tableext 50123 Customer Extend.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
tableextension 50123 "Customer Ext" extends Customer
{
fields
{
field(50100;"Reward ID";Code[30])
{
// Set links to the "Reward ID" from the Reward table.
TableRelation = Reward."Reward ID";
// Set whether to validate a table relationship.
ValidateTableRelation = true;
// "OnValidate" trigger executes when data is entered in a field.
trigger OnValidate();
begin
// If the "Reward ID" changed and the new record is blocked, an error is thrown.
if (Rec."Reward ID" <> xRec."Reward ID") and
(Rec.Blocked <> Blocked::" ") then
begin
Error('Cannot update the rewards status of a blocked customer.')
end;
end;
}
}
procedure UpdateCreditLimit(NewCreditLimit: Decimal)
begin
Rec.Validate("Credit Limit (LCY)", NewCreditLimit);
Rec.Modify();
end;
procedure CalculateCreditLimit(): Decimal
var
Cust: Record Customer;
begin
Cust := Rec;
Cust.SetRange("Date Filter", CalcDate('-12M', WorkDate()), WorkDate());
Cust.CalcFields("Sales (LCY)");
exit(Round(Cust."Sales (LCY)"))
end;
}