-
Notifications
You must be signed in to change notification settings - Fork 695
Expand file tree
/
Copy pathCreateLocationAT.Codeunit.al
More file actions
55 lines (49 loc) · 2.75 KB
/
CreateLocationAT.Codeunit.al
File metadata and controls
55 lines (49 loc) · 2.75 KB
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
// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------
namespace Microsoft.DemoData.Inventory;
using Microsoft.DemoData.Foundation;
using Microsoft.Inventory.Location;
codeunit 11167 "Create Location AT"
{
SingleInstance = true;
EventSubscriberInstance = Manual;
InherentEntitlements = X;
InherentPermissions = X;
[EventSubscriber(ObjectType::Table, Database::Location, 'OnBeforeInsertEvent', '', false, false)]
local procedure OnBeforeInsertLocation(var Rec: Record Location)
var
CreateLocation: Codeunit "Create Location";
CreateCountryRegion: Codeunit "Create Country/Region";
begin
case Rec.Code of
CreateLocation.EastLocation():
ValidateLocation(Rec, EastLocationAddressLbl, LocationCityLbl, EastLocationContactLbl, EastLocationPostCodeLbl, CreateCountryRegion.GB());
CreateLocation.MainLocation():
ValidateLocation(Rec, MainLocationAddressLbl, LocationCityLbl, MainLocationContactLbl, MainLocationPostCodeLbl, CreateCountryRegion.GB());
CreateLocation.WestLocation():
ValidateLocation(Rec, WestLocationAddressLbl, LocationCityLbl, WestLocationContactLbl, WestLocationPostCodeLbl, CreateCountryRegion.GB());
end;
end;
local procedure ValidateLocation(var Location: Record Location; Address: Text[100]; City: Text[30]; Contact: Text[100]; PostCode: Code[20]; CountryRegionCode: Code[10])
begin
Location.Validate(Address, Address);
Location.Validate("Address 2", '');
Location.Validate("Post Code", PostCode);
Location.Validate(City, City);
Location.Validate(Contact, Contact);
Location."Country/Region Code" := CountryRegionCode;
end;
var
EastLocationAddressLbl: Label 'Main Liverpool Street, 5', MaxLength = 100, Locked = true;
MainLocationAddressLbl: Label 'Main Bristol Street, 10', MaxLength = 100, Locked = true;
WestLocationAddressLbl: Label 'South East Street, 3', MaxLength = 100, Locked = true;
LocationCityLbl: Label 'Wien', MaxLength = 30;
EastLocationContactLbl: Label 'Chris Preston', MaxLength = 100;
MainLocationContactLbl: Label 'Jeanne Bosworth', MaxLength = 100;
WestLocationContactLbl: Label 'Jeff Smith', MaxLength = 100;
EastLocationPostCodeLbl: Label '1100', MaxLength = 20;
MainLocationPostCodeLbl: Label '1010', MaxLength = 20;
WestLocationPostCodeLbl: Label '1230', MaxLength = 20;
}