Table 5051 Contact Alt. Address

Base Application, Microsoft.CRM.Contact

src/Layers/W1/BaseApp/CRM/Contact/ContactAltAddress.Table.al300 lines, Copyright (c) Microsoft Corporation. MIT

// ------------------------------------------------------------------------------------------------// Copyright (c) Microsoft Corporation. All rights reserved.// Licensed under the MIT License. See License.txt in the project root for license information.// ------------------------------------------------------------------------------------------------namespace Microsoft.CRM.Contact;using Microsoft.Foundation.Address;using System;using System.Email;table 5051 "Contact Alt. Address"{    Caption = 'Contact Alt. Address';    DataCaptionFields = "Contact No.", "Code", "Company Name";    DataClassification = CustomerContent;    LookupPageID = "Contact Alt. Address List";    Permissions = TableData Contact = rm,                  TableData "Contact Alt. Addr. Date Range" = rd;    fields    {        field(1; "Contact No."; Code[20])        {            Caption = 'Contact No.';            TableRelation = Contact;        }        field(2; "Code"; Code[10])        {            Caption = 'Code';            ToolTip = 'Specifies the code for the alternate address.';            NotBlank = true;        }        field(3; "Company Name"; Text[100])        {            Caption = 'Company Name';            ToolTip = 'Specifies the name of the company for the alternate address.';        }        field(4; "Company Name 2"; Text[50])        {            Caption = 'Company Name 2';            ToolTip = 'Specifies the additional part of the company name for the alternate address.';        }        field(5; Address; Text[100])        {            Caption = 'Address';            ToolTip = 'Specifies the alternate address of the contact.';        }        field(6; "Address 2"; Text[50])        {            Caption = 'Address 2';            ToolTip = 'Specifies additional address information.';        }        field(7; City; Text[30])        {            Caption = 'City';            ToolTip = 'Specifies the city of the contact''s alternate address.';            TableRelation = if ("Country/Region Code" = const('')) "Post Code".City            else            if ("Country/Region Code" = filter(<> '')) "Post Code".City where("Country/Region Code" = field("Country/Region Code"));            ValidateTableRelation = false;            trigger OnLookup()            begin                LookupPostCode(Rec.FieldNo(City));            end;            trigger OnValidate()            var                IsHandled: Boolean;            begin                IsHandled := false;                OnBeforeValidateCity(Rec, PostCode, CurrFieldNo, IsHandled);                if not IsHandled then                    PostCode.ValidateCity(City, "Post Code", County, "Country/Region Code", (CurrFieldNo <> 0) and GuiAllowed);            end;        }        field(8; "Post Code"; Code[20])        {            Caption = 'Post Code';            ToolTip = 'Specifies the postal code.';            TableRelation = if ("Country/Region Code" = const('')) "Post Code"            else            if ("Country/Region Code" = filter(<> '')) "Post Code" where("Country/Region Code" = field("Country/Region Code"));            ValidateTableRelation = false;            trigger OnLookup()            begin                LookupPostCode(Rec.FieldNo("Post Code"));            end;            trigger OnValidate()            var                IsHandled: Boolean;            begin                IsHandled := false;                OnBeforeValidatePostCode(Rec, PostCode, CurrFieldNo, IsHandled);                if not IsHandled then                    PostCode.ValidatePostCode(City, "Post Code", County, "Country/Region Code", (CurrFieldNo <> 0) and GuiAllowed);            end;        }        field(9; County; Text[30])        {            CaptionClass = '5,1,' + "Country/Region Code";            Caption = 'County';            ToolTip = 'Specifies the county for the contact''s alternate address.';        }        field(10; "Country/Region Code"; Code[10])        {            Caption = 'Country/Region Code';            ToolTip = 'Specifies the country/region of the address.';            TableRelation = "Country/Region";            trigger OnValidate()            begin                PostCode.CheckClearPostCodeCityCounty(City, "Post Code", County, "Country/Region Code", xRec."Country/Region Code");            end;        }        field(12; "Phone No."; Text[30])        {            Caption = 'Phone No.';            ToolTip = 'Specifies the telephone number for the alternate address.';            ExtendedDatatype = PhoneNo;            trigger OnValidate()            var                Char: DotNet Char;                i: Integer;            begin                for i := 1 to StrLen("Phone No.") do                    if Char.IsLetter("Phone No."[i]) then                        FieldError("Phone No.", PhoneNoCannotContainLettersErr);            end;        }        field(13; "Telex No."; Text[20])        {            Caption = 'Telex No.';            ToolTip = 'Specifies the telex number for the alternate address.';        }        field(14; "Extension No."; Text[30])        {            Caption = 'Extension No.';        }        field(15; "Mobile Phone No."; Text[30])        {            Caption = 'Mobile Phone No.';            ToolTip = 'Specifies the mobile phone number for the alternate address.';            ExtendedDatatype = PhoneNo;            trigger OnValidate()            var                Char: DotNet Char;                i: Integer;            begin                for i := 1 to StrLen("Mobile Phone No.") do                    if Char.IsLetter("Mobile Phone No."[i]) then                        FieldError("Mobile Phone No.", PhoneNoCannotContainLettersErr);            end;        }        field(16; Pager; Text[30])        {            Caption = 'Pager';            ToolTip = 'Specifies the pager number for the contact at the alternate address.';        }        field(17; "E-Mail"; Text[80])        {            Caption = 'Email';            ToolTip = 'Specifies the e-mail address for the contact at the alternate address.';            ExtendedDatatype = EMail;            trigger OnValidate()            var                MailManagement: Codeunit "Mail Management";            begin                MailManagement.ValidateEmailAddressField("E-Mail");                SetSearchEmail();            end;        }#if not CLEAN27#pragma warning disable AS0086#endif        field(18; "Home Page"; Text[255])#if not CLEAN27#pragma warning restore AS0086#endif        {            Caption = 'Home Page';            ToolTip = 'Specifies the contact''s web site.';            ExtendedDatatype = URL;        }        field(19; "Fax No."; Text[30])        {            Caption = 'Fax No.';            ToolTip = 'Specifies the fax number for the alternate address.';        }        field(20; "Telex Answer Back"; Text[20])        {            Caption = 'Telex Answer Back';            ToolTip = 'Specifies the telex answer back number for the alternate address.';        }        field(21; "Last Date Modified"; Date)        {            Caption = 'Last Date Modified';        }        field(22; "Search E-Mail"; Code[80])        {            Caption = 'Search Email';        }    }    keys    {        key(Key1; "Contact No.", "Code")        {            Clustered = true;        }        key(Key2; "Search E-Mail")        {        }    }    fieldgroups    {        fieldgroup(DropDown; "Code", "Company Name", Address, City, "Post Code")        {        }    }    trigger OnDelete()    var        Contact: Record Contact;        ContAltAddrDateRange: Record "Contact Alt. Addr. Date Range";    begin        Contact.TouchContact("Contact No.");        ContAltAddrDateRange.SetRange("Contact No.", "Contact No.");        ContAltAddrDateRange.SetRange("Contact Alt. Address Code", Code);        ContAltAddrDateRange.DeleteAll();    end;    trigger OnInsert()    var        Contact: Record Contact;    begin        SetSearchEmail();        Contact.TouchContact("Contact No.");    end;    trigger OnModify()    var        Contact: Record Contact;    begin        SetSearchEmail();        "Last Date Modified" := Today;        Contact.TouchContact("Contact No.");    end;    trigger OnRename()    var        Contact: Record Contact;    begin        if xRec."Contact No." = "Contact No." then            Contact.TouchContact("Contact No.")        else begin            Contact.TouchContact("Contact No.");            Contact.TouchContact(xRec."Contact No.");        end;    end;    var        PostCode: Record "Post Code";        PhoneNoCannotContainLettersErr: Label 'must not contain letters';    local procedure SetSearchEmail()    begin        if "Search E-Mail" <> "E-Mail".ToUpper() then            "Search E-Mail" := "E-Mail";    end;    local procedure LookupPostCode(CalledFromField: Integer)    begin        PostCode.LookupPostCode(Rec.City, Rec."Post Code", Rec.County, Rec."Country/Region Code");        OnAfterLookupPostCode(Rec, CalledFromField, PostCode);    end;    [IntegrationEvent(false, false)]    local procedure OnAfterLookupPostCode(var ContactAltAddress: Record "Contact Alt. Address"; FieldNo: Integer; var PostCode: Record "Post Code")    begin    end;    [IntegrationEvent(false, false)]    local procedure OnBeforeValidateCity(var ContactAltAddress: Record "Contact Alt. Address"; var PostCode: Record "Post Code"; CurrentFieldNo: Integer; var IsHandled: Boolean);    begin    end;    [IntegrationEvent(false, false)]    local procedure OnBeforeValidatePostCode(var ContactAltAddress: Record "Contact Alt. Address"; var PostCode: Record "Post Code"; CurrentFieldNo: Integer; var IsHandled: Boolean)    begin    end;}