Page 5342 CRM Contact List

Base Application, Microsoft.Integration.D365Sales

src/Layers/W1/BaseApp/Integration/D365Sales/CRMContactList.Page.al212 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.Integration.D365Sales;using Microsoft.CRM.Contact;using Microsoft.Integration.Dataverse;page 5342 "CRM Contact List"{    ApplicationArea = Suite;    Caption = 'Contacts - Dataverse';    AdditionalSearchTerms = 'Contacts CDS, Contacts Common Data Service';    Editable = false;    PageType = List;    SourceTable = "CRM Contact";    SourceTableView = sorting(FullName);    UsageCategory = Lists;    layout    {        area(content)        {            repeater(Control2)            {                ShowCaption = false;                field(FullName; Rec.FullName)                {                    ApplicationArea = Suite;                    Caption = 'Name';                    StyleExpr = FirstColumnStyle;                }                field(Address1_Line1; Rec.Address1_Line1)                {                    ApplicationArea = Suite;                    Caption = 'Street 1';                }                field(Address1_Line2; Rec.Address1_Line2)                {                    ApplicationArea = Suite;                    Caption = 'Street 2';                }                field(Address1_PostalCode; Rec.Address1_PostalCode)                {                    ApplicationArea = Suite;                    Caption = 'ZIP/Postal Code';                }                field(Address1_City; Rec.Address1_City)                {                    ApplicationArea = Suite;                    Caption = 'City';                }                field(Address1_Country; Rec.Address1_Country)                {                    ApplicationArea = Suite;                    Caption = 'Country/Region';                }                field(EMailAddress1; Rec.EMailAddress1)                {                    ApplicationArea = Suite;                    Caption = 'Email Address';                    ExtendedDatatype = EMail;                }                field(Fax; Rec.Fax)                {                    ApplicationArea = Suite;                    Caption = 'Fax';                }                field(WebSiteUrl; Rec.WebSiteUrl)                {                    ApplicationArea = Suite;                    Caption = 'Website URL';                }                field(MobilePhone; Rec.MobilePhone)                {                    ApplicationArea = Suite;                    Caption = 'Mobile Phone';                }                field(Pager; Rec.Pager)                {                    ApplicationArea = Suite;                    Caption = 'Pager';                }                field(Telephone1; Rec.Telephone1)                {                    ApplicationArea = Suite;                    Caption = 'Telephone';                }                field(Coupled; Coupled)                {                    ApplicationArea = Suite;                    Caption = 'Coupled';                    ToolTip = 'Specifies if the Dataverse record is coupled to Business Central.';                }            }        }    }    actions    {        area(processing)        {            action(CreateFromCRM)            {                ApplicationArea = Suite;                Caption = 'Create Contact in Business Central';                Image = NewCustomer;                ToolTip = 'Create a contact in Dynamics 365 that is linked to the Dataverse contact.';                trigger OnAction()                var                    CRMContact: Record "CRM Contact";                    CRMIntegrationManagement: Codeunit "CRM Integration Management";                begin                    CurrPage.SetSelectionFilter(CRMContact);                    CRMIntegrationManagement.CreateNewRecordsFromSelectedCRMRecords(CRMContact);                end;            }            action(ShowOnlyUncoupled)            {                ApplicationArea = Suite;                Caption = 'Hide Coupled Contacts';                Image = FilterLines;                ToolTip = 'Do not show coupled contacts.';                trigger OnAction()                begin                    Rec.MarkedOnly(true);                end;            }            action(ShowAll)            {                ApplicationArea = Suite;                Caption = 'Show Coupled Contacts';                Image = ClearFilter;                ToolTip = 'Show coupled contacts.';                trigger OnAction()                begin                    Rec.MarkedOnly(false);                end;            }        }        area(Promoted)        {            group(Category_Process)            {                Caption = 'Process';                actionref(CreateFromCRM_Promoted; CreateFromCRM)                {                }                actionref(ShowOnlyUncoupled_Promoted; ShowOnlyUncoupled)                {                }                actionref(ShowAll_Promoted; ShowAll)                {                }            }        }    }    trigger OnAfterGetRecord()    var        CRMIntegrationRecord: Record "CRM Integration Record";        RecordID: RecordID;    begin        if CRMIntegrationRecord.FindRecordIDFromID(Rec.ContactId, DATABASE::Contact, RecordID) then            if CurrentlyCoupledCRMContact.ContactId = Rec.ContactId then begin                Coupled := 'Current';                FirstColumnStyle := 'Strong';                Rec.Mark(true);            end else begin                Coupled := 'Yes';                FirstColumnStyle := 'Subordinate';                Rec.Mark(false);            end        else begin            Coupled := 'No';            FirstColumnStyle := 'None';            Rec.Mark(true);        end;    end;    trigger OnInit()    begin        CODEUNIT.Run(CODEUNIT::"CRM Integration Management");        Commit();    end;    trigger OnOpenPage()    var        LookupCRMTables: Codeunit "Lookup CRM Tables";    begin        Rec.FilterGroup(4);        Rec.SetView(LookupCRMTables.GetIntegrationTableMappingView(DATABASE::"CRM Contact"));        Rec.FilterGroup(0);    end;    var        CurrentlyCoupledCRMContact: Record "CRM Contact";        Coupled: Text;        FirstColumnStyle: Text;    procedure SetCurrentlyCoupledCRMContact(CRMContact: Record "CRM Contact")    begin        CurrentlyCoupledCRMContact := CRMContact;    end;}