Page 21 Customer Card

Base Application, Microsoft.Sales.Customer

src/Layers/W1/BaseApp/Sales/Customer/CustomerCard.Page.al2,965 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.Sales.Customer;using Microsoft.Bank.DirectDebit;using Microsoft.Bank.Payment;using Microsoft.CRM.Contact;using Microsoft.CRM.Duplicates;using Microsoft.CRM.Outlook;using Microsoft.Finance.Dimension;using Microsoft.Finance.GeneralLedger.Journal;using Microsoft.Finance.VAT.Registration;using Microsoft.Foundation.Address;using Microsoft.Foundation.Attachment;using Microsoft.Foundation.Calendar;using Microsoft.Foundation.Comment;using Microsoft.Foundation.Reporting;using Microsoft.Integration.D365Sales;using Microsoft.Integration.Dataverse;using Microsoft.Integration.SyncEngine;using Microsoft.Inventory.Item.Catalog;using Microsoft.Inventory.Tracking;using Microsoft.Pricing.Calculation;using Microsoft.Pricing.PriceList;using Microsoft.Pricing.Source;using Microsoft.Projects.Project.Job;using Microsoft.Sales.Analysis;using Microsoft.Sales.Document;using Microsoft.Sales.FinanceCharge;using Microsoft.Sales.Pricing;using Microsoft.Sales.Receivables;using Microsoft.Sales.Reminder;using Microsoft.Sales.Reports;using Microsoft.Sales.Setup;using Microsoft.Utilities;using System.Automation;using System.Email;using System.Environment;using System.Environment.Configuration;using System.Integration.Word;using System.Privacy;/// <summary>/// Provides detailed view and management of an individual customer's master data./// </summary>page 21 "Customer Card"{    Caption = 'Customer Card';    PageType = Card;    RefreshOnActivate = true;    SourceTable = Customer;    AdditionalSearchTerms = 'Customer Profile, Client Details, Buyer Information, Customer Data, Customer View, Client Profile, Customer Detail, Client Info';    AboutTitle = 'About customer details';    AboutText = 'With the **Customer Card** you manage information about a customer and specify the terms of business, such as payment terms, prices and discounts. From here you can also drill down on past and ongoing sales activity.';    layout    {        area(content)        {            group(General)            {                Caption = 'General';                field("No."; Rec."No.")                {                    ApplicationArea = All;                    Importance = Standard;                    Visible = NoFieldVisible;                    trigger OnAssistEdit()                    begin                        if Rec.AssistEdit(xRec) then                            CurrPage.Update();                    end;                }                field(Name; Rec.Name)                {                    ApplicationArea = All;                    Importance = Promoted;                    ShowMandatory = true;                    trigger OnValidate()                    begin                        CurrPage.Update(true);                    end;                }                field("Name 2"; Rec."Name 2")                {                    ApplicationArea = All;                    Importance = Additional;                    Visible = false;                }                field("Search Name"; Rec."Search Name")                {                    ApplicationArea = All;                    Importance = Additional;                    Visible = false;                }                field("IC Partner Code"; Rec."IC Partner Code")                {                    ApplicationArea = Intercompany;                    Importance = Additional;                }                field("Balance (LCY)"; Rec."Balance (LCY)")                {                    ApplicationArea = Basic, Suite;                    trigger OnDrillDown()                    begin                        Rec.OpenCustomerLedgerEntries(false);                    end;                }                field(BalanceAsVendor; BalanceAsVendor)                {                    ApplicationArea = Basic, Suite;                    AutoFormatType = 1;                    AutoFormatExpression = '';                    Caption = 'Balance (LCY) As Vendor';                    Editable = false;                    Enabled = BalanceAsVendorEnabled;                    ToolTip = 'Specifies the amount that you owe to this company. This is relevant when your customer is also your vendor. Customer and vendor are linked together through their contact record. Using customer''s contact record you can create linked vendor or link contact with existing vendor to enable calculation of Balance As Vendor amount.';                    trigger OnDrillDown()                    var                        DtldVendLedgEntry: Record 380;                        VendLedgEntry: Record 25;                    begin                        if LinkedVendorNo = '' then                            exit;                        DtldVendLedgEntry.SetRange("Vendor No.", LinkedVendorNo);                        Rec.CopyFilter("Global Dimension 1 Filter", DtldVendLedgEntry."Initial Entry Global Dim. 1");                        Rec.CopyFilter("Global Dimension 2 Filter", DtldVendLedgEntry."Initial Entry Global Dim. 2");                        Rec.CopyFilter("Currency Filter", DtldVendLedgEntry."Currency Code");                        VendLedgEntry.DrillDownOnEntries(DtldVendLedgEntry);                    end;                }                field("Balance Due (LCY)"; Rec."Balance Due (LCY)")                {                    ApplicationArea = Basic, Suite;                    trigger OnDrillDown()                    begin                        Rec.OpenCustomerLedgerEntries(true);                    end;                }                field("Credit Limit (LCY)"; Rec."Credit Limit (LCY)")                {                    ApplicationArea = Basic, Suite;                    StyleExpr = StyleTxt;                    trigger OnValidate()                    begin                        SetCreditLimitStyle();                    end;                }                field(Blocked; Rec.Blocked)                {                    ApplicationArea = Basic, Suite;                }                field("Privacy Blocked"; Rec."Privacy Blocked")                {                    ApplicationArea = Basic, Suite;                    Importance = Additional;                }                field("Salesperson Code"; Rec."Salesperson Code")                {                    ApplicationArea = Suite;                    Importance = Additional;                }                field("Responsibility Center"; Rec."Responsibility Center")                {                    ApplicationArea = Suite;                    Importance = Additional;                }                field("Document Sending Profile"; Rec."Document Sending Profile")                {                    ApplicationArea = Basic, Suite;                    Importance = Additional;                }                field(TotalSales2; CustSalesLCY)                {                    ApplicationArea = Basic, Suite;                    AutoFormatType = 1;                    AutoFormatExpression = '';                    Caption = 'Total Sales - Fiscal Year';                    Style = Strong;                    StyleExpr = true;                    Editable = false;                    ToolTip = 'Specifies your total sales turnover with the customer in the current fiscal year. It is calculated from amounts excluding VAT on all completed and open invoices and credit memos.';                    trigger OnDrillDown()                    begin                        OpenCurrFiscalYearCustLedgerEntries();                    end;                }                field("CustSalesLCY - CustProfit - AdjmtCostLCY"; CustSalesLCY - CustProfit - AdjmtCostLCY)                {                    ApplicationArea = Basic, Suite;                    AutoFormatType = 1;                    AutoFormatExpression = '';                    Caption = 'Costs (LCY)';                    ToolTip = 'Specifies how much cost you have incurred from the customer in the current fiscal year.';                }                field(AdjCustProfit; AdjCustProfit)                {                    ApplicationArea = Basic, Suite;                    AutoFormatType = 1;                    AutoFormatExpression = '';                    Caption = 'Profit (LCY)';                    Editable = false;                    Importance = Additional;                    ToolTip = 'Specifies how much profit you have made from the customer in the current fiscal year.';                }                field(AdjProfitPct; AdjProfitPct)                {                    ApplicationArea = Basic, Suite;                    AutoFormatType = 0;                    Caption = 'Profit %';                    DecimalPlaces = 1 : 1;                    Editable = false;                    Importance = Additional;                    ToolTip = 'Specifies how much profit you have made from the customer in the current fiscal year, expressed as a percentage of the customer''s total sales.';                }                field("Last Date Modified"; Rec."Last Date Modified")                {                    ApplicationArea = Basic, Suite;                    Importance = Additional;                }                field("Disable Search by Name"; Rec."Disable Search by Name")                {                    ApplicationArea = Basic, Suite;                    Importance = Additional;                }                field(Priority; Rec.Priority)                {                    ApplicationArea = Basic, Suite;                    Importance = Additional;                    Visible = false;                }                field("Statistics Group"; Rec."Statistics Group")                {                    ApplicationArea = Basic, Suite;                    Visible = false;                }            }            group("Address & Contact")            {                Caption = 'Address & Contact';                group(AddressDetails)                {                    Caption = 'Address';                    field(Address; Rec.Address)                    {                        ApplicationArea = Basic, Suite;                    }                    field("Address 2"; Rec."Address 2")                    {                        ApplicationArea = Basic, Suite;                    }                    field("Country/Region Code"; Rec."Country/Region Code")                    {                        ApplicationArea = Basic, Suite;                        trigger OnValidate()                        begin                            IsCountyVisible := FormatAddress.UseCounty(Rec."Country/Region Code");                        end;                    }                    field(City; Rec.City)                    {                        ApplicationArea = Basic, Suite;                    }                    group(Control10)                    {                        ShowCaption = false;                        Visible = IsCountyVisible;                        field(County; Rec.County)                        {                            ApplicationArea = Basic, Suite;                        }                    }                    field("Post Code"; Rec."Post Code")                    {                        ApplicationArea = Basic, Suite;                        Importance = Promoted;                    }                    field(ShowMap; ShowMapLbl)                    {                        ApplicationArea = Basic, Suite;                        Editable = false;                        ShowCaption = false;                        Style = StrongAccent;                        StyleExpr = true;                        ToolTip = 'Specifies the customer''s address on your preferred map website.';                        trigger OnDrillDown()                        begin                            CurrPage.Update(true);                            Rec.DisplayMap();                        end;                    }                }                field("Phone No."; Rec."Phone No.")                {                    ApplicationArea = Basic, Suite;                }                field(MobilePhoneNo; Rec."Mobile Phone No.")                {                    ApplicationArea = Basic, Suite;                    ExtendedDatatype = PhoneNo;                }                field("E-Mail"; Rec."E-Mail")                {                    ApplicationArea = Basic, Suite;                    ExtendedDatatype = EMail;                    Importance = Promoted;                }                field("Fax No."; Rec."Fax No.")                {                    ApplicationArea = Basic, Suite;                    Importance = Additional;                }                field("Home Page"; Rec."Home Page")                {                    ApplicationArea = Basic, Suite;                }                field("Language Code"; Rec."Language Code")                {                    ApplicationArea = Basic, Suite;                    Importance = Additional;                }                field("Format Region"; Rec."Format Region")                {                    ApplicationArea = Basic, Suite;                    Importance = Additional;                }                group(ContactDetails)                {                    Caption = 'Contact';                    field("Primary Contact No."; Rec."Primary Contact No.")                    {                        ApplicationArea = Basic, Suite;                        Caption = 'Contact Code';                        Importance = Additional;                    }                    field(ContactName; Rec.Contact)                    {                        ApplicationArea = Basic, Suite;                        Caption = 'Contact Name';                        Editable = ContactEditable;                        Importance = Promoted;                        trigger OnValidate()                        begin                            ActivateFields();                        end;                    }                }            }            group(Invoicing)            {                Caption = 'Invoicing';                AboutTitle = 'Manage the customer''s invoicing';                AboutText = 'Specify tax settings and choose how invoicing takes place for the customer. Assign posting groups to control how the customer''s transactions are grouped and posted, based on type of trade or market.';                field("Bill-to Customer No."; Rec."Bill-to Customer No.")                {                    ApplicationArea = Basic, Suite;                    Caption = 'Bill-to Customer';                    Importance = Additional;                }                field("VAT Registration No."; Rec."VAT Registration No.")                {                    ApplicationArea = VAT;                    trigger OnDrillDown()                    var                        VATRegistrationLogMgt: Codeunit "VAT Registration Log Mgt.";                    begin                        VATRegistrationLogMgt.AssistEditCustomerVATReg(Rec);                    end;                }                field("EORI Number"; Rec."EORI Number")                {                    ApplicationArea = Basic, Suite;                }                field(GLN; Rec.GLN)                {                    ApplicationArea = Basic, Suite;                    Importance = Additional;                }                field("Use GLN in Electronic Document"; Rec."Use GLN in Electronic Document")                {                    ApplicationArea = Basic, Suite;                }                field("Copy Sell-to Addr. to Qte From"; Rec."Copy Sell-to Addr. to Qte From")                {                    ApplicationArea = Basic, Suite;                }                field("Tax Liable"; Rec."Tax Liable")                {                    ApplicationArea = SalesTax;                }                field("Tax Area Code"; Rec."Tax Area Code")                {                    ApplicationArea = SalesTax;                }                field("Registration Number"; Rec."Registration Number")                {                    ApplicationArea = Basic, Suite;                    Importance = Additional;                }                group(PostingDetails)                {                    Caption = 'Posting Details';                    field("Gen. Bus. Posting Group"; Rec."Gen. Bus. Posting Group")                    {                        ApplicationArea = Basic, Suite;                        Importance = Promoted;                        ShowMandatory = true;                    }                    field("VAT Bus. Posting Group"; Rec."VAT Bus. Posting Group")                    {                        ApplicationArea = Basic, Suite;                        Importance = Additional;                    }                    field("Customer Posting Group"; Rec."Customer Posting Group")                    {                        ApplicationArea = Basic, Suite;                        Importance = Promoted;                        ShowMandatory = true;                    }                    field("Allow Multiple Posting Groups"; Rec."Allow Multiple Posting Groups")                    {                        ApplicationArea = Basic, Suite;                        Importance = Additional;                        Visible = IsAllowMultiplePostingGroupsVisible;                    }                }                group(PricesandDiscounts)                {                    Caption = 'Prices and Discounts';                    field("Currency Code"; Rec."Currency Code")                    {                        ApplicationArea = Suite;                        Importance = Additional;                    }                    field("Price Calculation Method"; Rec."Price Calculation Method")                    {                        Visible = ExtendedPriceEnabled;                        ApplicationArea = Basic, Suite;                        Importance = Promoted;                    }                    field("Customer Price Group"; Rec."Customer Price Group")                    {                        ApplicationArea = Basic, Suite;                        Importance = Promoted;                    }                    field("Customer Disc. Group"; Rec."Customer Disc. Group")                    {                        ApplicationArea = Basic, Suite;                        Importance = Promoted;                    }                    field("Allow Line Disc."; Rec."Allow Line Disc.")                    {                        ApplicationArea = Basic, Suite;                        Importance = Additional;                    }                    field("Invoice Disc. Code"; Rec."Invoice Disc. Code")                    {                        ApplicationArea = Basic, Suite;                        Importance = Additional;                        NotBlank = true;                    }                    field("Prices Including VAT"; Rec."Prices Including VAT")                    {                        ApplicationArea = VAT;                        Importance = Additional;                    }                }            }            group(Payments)            {                Caption = 'Payments';                AboutTitle = 'Manage the customer''s payment';                AboutText = 'Specify the customer''s default payment terms and settings for how payments from the customer is processed.';                field("Prepayment %"; Rec."Prepayment %")                {                    ApplicationArea = Prepayments;                    Importance = Additional;                }                field("Application Method"; Rec."Application Method")                {                    ApplicationArea = Basic, Suite;                    Importance = Additional;                }                field("Partner Type"; Rec."Partner Type")                {                    ApplicationArea = Basic, Suite;                    Importance = Additional;                }                field("Intrastat Partner Type"; Rec."Intrastat Partner Type")                {                    ApplicationArea = Basic, Suite;                    Importance = Additional;                }                field("Payment Terms Code"; Rec."Payment Terms Code")                {                    ApplicationArea = Basic, Suite;                    Importance = Promoted;                    ShowMandatory = true;                }                field("Payment Method Code"; Rec."Payment Method Code")                {                    ApplicationArea = Basic, Suite;                    Importance = Additional;                }                field("Reminder Terms Code"; Rec."Reminder Terms Code")                {                    ApplicationArea = Suite;                    Importance = Additional;                }                field("Fin. Charge Terms Code"; Rec."Fin. Charge Terms Code")                {                    ApplicationArea = Suite;                    Importance = Additional;                }                field("Cash Flow Payment Terms Code"; Rec."Cash Flow Payment Terms Code")                {                    ApplicationArea = Basic, Suite;                    Importance = Additional;                }                field("Print Statements"; Rec."Print Statements")                {                    ApplicationArea = Basic, Suite;                    Importance = Additional;                }                field("Last Statement No."; Rec."Last Statement No.")                {                    ApplicationArea = Basic, Suite;                    Importance = Additional;                }                field("Block Payment Tolerance"; Rec."Block Payment Tolerance")                {                    ApplicationArea = Basic, Suite;                    Importance = Additional;                }                field("Preferred Bank Account Code"; Rec."Preferred Bank Account Code")                {                    ApplicationArea = Basic, Suite;                    Importance = Additional;                }                field("Exclude from Pmt. Practices"; Rec."Exclude from Pmt. Practices")                {                    ApplicationArea = Basic, Suite;                    Importance = Additional;                }            }            group(Shipping)            {                Caption = 'Shipping';                field("Ship-to Code"; Rec."Ship-to Code")                {                    ApplicationArea = Basic, Suite;                }                field("Location Code"; Rec."Location Code")                {                    ApplicationArea = Location;                    Importance = Promoted;                }                field("Combine Shipments"; Rec."Combine Shipments")                {                    ApplicationArea = Basic, Suite;                }                field(Reserve; Rec.Reserve)                {                    ApplicationArea = Reservation;                }                field("Shipping Advice"; Rec."Shipping Advice")                {                    ApplicationArea = Basic, Suite;                    Importance = Promoted;                }                group("Shipment Method")                {                    Caption = 'Shipment Method';                    field("Shipment Method Code"; Rec."Shipment Method Code")                    {                        ApplicationArea = Basic, Suite;                        Caption = 'Code';                        Importance = Promoted;                    }                    field("Shipping Agent Code"; Rec."Shipping Agent Code")                    {                        ApplicationArea = Suite;                        Caption = 'Agent';                        Importance = Additional;                    }                    field("Shipping Agent Service Code"; Rec."Shipping Agent Service Code")                    {                        ApplicationArea = Suite;                        Caption = 'Agent Service';                        Importance = Additional;                    }                }                field("Shipping Time"; Rec."Shipping Time")                {                    ApplicationArea = Suite;                    Importance = Additional;                }                field("Base Calendar Code"; Rec."Base Calendar Code")                {                    ApplicationArea = Basic, Suite;                    DrillDown = false;                }                field("Customized Calendar"; Format(HasCustomBaseCalendar()))                {                    ApplicationArea = Basic, Suite;                    Caption = 'Customized Calendar';                    Editable = false;                    ToolTip = 'Specifies that you have set up a customized version of a base calendar.';                    trigger OnDrillDown()                    begin                        CurrPage.SaveRecord();                        Rec.TestField("Base Calendar Code");                        CalendarMgmt.ShowCustomizedCalendar(Rec);                    end;                }            }            group(Statistics)            {                Caption = 'Statistics';                Editable = false;                Visible = FoundationOnly;                group(GeneralStats)                {                    Caption = 'General';                    field(CustomerSince; Rec."First Transaction Date")                    {                        ApplicationArea = Basic, Suite;                        Caption = 'Customer Since';                        ToolTip = 'Specifies the date when the first transaction with the customer was recorded.';                        Importance = Additional;                    }                    field(DaysSinceLastSale; DaysSinceLastSale)                    {                        ApplicationArea = Basic, Suite;                        Caption = 'Days Since Last Sale';                        ToolTip = 'Specifies the number of days since you last had a sale to the customer.';                        Importance = Additional;                    }                    field(DistinctItemsSold; DistinctItemsSold)                    {                        ApplicationArea = Basic, Suite;                        Caption = 'Distinct Items Sold';                        ToolTip = 'Specifies the number of distinct items that you have sold to the customer in the current fiscal year.';                        Importance = Additional;                    }                }                group(Balance)                {                    Caption = 'Balance';                    field("Balance (LCY)2"; Rec."Balance (LCY)")                    {                        ApplicationArea = Basic, Suite;                        Caption = 'Money Owed - Current';                        trigger OnDrillDown()                        begin                            Rec.OpenCustomerLedgerEntries(false);                        end;                    }                    field(ExpectedCustMoneyOwed; ExpectedMoneyOwed)                    {                        ApplicationArea = Basic, Suite;                        AutoFormatType = 1;                        AutoFormatExpression = Rec."Currency Code";                        Caption = 'Money Owed - Expected';                        Editable = false;                        Importance = Additional;                        ToolTip = 'Specifies the payment amount that the customer will owe when ongoing sales invoices and credit memos are completed. The value is calculated asynchronously so there might be a delay in updating this field.';                        trigger OnDrillDown()                        begin                            CustomerMgt.DrillDownMoneyOwedExpected(Rec."No.");                        end;                    }                    field(TotalMoneyOwed; TotalMoneyOwed)                    {                        ApplicationArea = Basic, Suite;                        AutoFormatType = 1;                        AutoFormatExpression = Rec."Currency Code";                        Caption = 'Money Owed - Total';                        Style = Strong;                        StyleExpr = true;                        ToolTip = 'Specifies the payment amount that the customer owes for completed sales plus sales that are still ongoing. The value is calculated asynchronously so there might be a delay in updating this field.';                    }                    field(CreditLimit; Rec."Credit Limit (LCY)")                    {                        ApplicationArea = Basic, Suite;                        Caption = 'Credit Limit';                    }                    field(CalcCreditLimitLCYExpendedPct; Rec.CalcCreditLimitLCYExpendedPct())                    {                        ApplicationArea = Basic, Suite;                        AutoFormatType = 0;                        Caption = 'Usage Of Credit Limit';                        ExtendedDatatype = Ratio;                        Style = Attention;                        StyleExpr = BalanceExhausted;                        ToolTip = 'Specifies how much of the customer''s payment balance consists of credit.';                    }                }                group(Control108)                {                    Caption = 'Payments';                    field("Balance Due"; OverdueBalance)                    {                        ApplicationArea = Basic, Suite;                        AutoFormatType = 1;                        AutoFormatExpression = Rec."Currency Code";                        CaptionClass = OverduePaymentsMsg;                        ToolTip = 'Specifies the sum of outstanding payments from the customer.';                        trigger OnDrillDown()                        var                            DtldCustLedgEntry: Record "Detailed Cust. Ledg. Entry";                            CustLedgEntry: Record "Cust. Ledger Entry";                        begin                            DtldCustLedgEntry.SetRange("Customer No.", Rec."No.");                            Rec.CopyFilter("Global Dimension 1 Filter", DtldCustLedgEntry."Initial Entry Global Dim. 1");                            Rec.CopyFilter("Global Dimension 2 Filter", DtldCustLedgEntry."Initial Entry Global Dim. 2");                            Rec.CopyFilter("Currency Filter", DtldCustLedgEntry."Currency Code");                            CustLedgEntry.DrillDownOnOverdueEntries(DtldCustLedgEntry);                        end;                    }                    field("Payments (LCY)"; CustPaymentsLCY)                    {                        ApplicationArea = Basic, Suite;                        AutoFormatType = 1;                        AutoFormatExpression = '';                        CaptionClass = Format(StrSubstNo(PaymentsThisYearTxt, Format(CustomerMgt.GetCurrentYearFilter())));                        ToolTip = 'Specifies the sum of payments received from the customer in the current fiscal year. Current fiscal year is determined by the system date. The value shown here is calculated asynchronously so there might be a delay in updating this field.';                        trigger OnDrillDown()                        begin                            OpenCurrFiscalYearDetailedCustLedgerEntries();                        end;                    }#pragma warning disable AA0100                    field("CustomerMgt.AvgDaysToPay(""No."")"; AvgDaysToPay)#pragma warning restore AA0100                    {                        ApplicationArea = Basic, Suite;                        AutoFormatType = 0;                        Caption = 'Average Collection Period (Days)';                        DecimalPlaces = 0 : 1;                        Importance = Additional;                        ToolTip = 'Specifies how long the customer typically takes to pay invoices in the current fiscal year. The value is calculated asynchronously so there might be a delay in updating this field.';                    }                    field(DaysPaidPastDueDate; DaysPastDueDate)                    {                        ApplicationArea = Basic, Suite;                        AutoFormatType = 0;                        Caption = 'Average Late Payments (Days)';                        DecimalPlaces = 0 : 1;                        Importance = Additional;                        Style = Attention;                        StyleExpr = AttentionToPaidDay;                        ToolTip = 'Specifies the average number of days the customer is late with payments. The value is calculated asynchronously so there might be a delay in updating this field.';                    }                    field(PaidLateCount; PaidLateCount)                    {                        ApplicationArea = Basic, Suite;                        Caption = 'Invoices Paid Late';                        ToolTip = 'Specifies the number of invoices that were paid late by the customer in the current fiscal year.';                        Importance = Additional;                    }                    field(PaidOnTimeCount; PaidOnTimeCount)                    {                        ApplicationArea = Basic, Suite;                        Caption = 'Invoices Paid On Time';                        ToolTip = 'Specifies the number of invoices that were paid on time by the customer in the current fiscal year.';                        Importance = Additional;                    }                    field(PercentPaidLate; PercentPaidLate)                    {                        ApplicationArea = Basic, Suite;                        AutoFormatType = 0;                        Caption = 'Percent Paid Late';                        ToolTip = 'Specifies the percentage of invoices that were paid late by the customer in the current fiscal year.';                        Importance = Additional;                        DecimalPlaces = 1 : 2;                    }                    field(OverdueCount; OverdueCount)                    {                        ApplicationArea = Basic, Suite;                        Caption = 'Overdue Payments Count';                        ToolTip = 'Specifies the number of overdue payments for the customer in the current fiscal year.';                        Importance = Additional;                    }                    field(LastPaymentDate; LastPaymentDate)                    {                        ApplicationArea = Basic, Suite;                        Caption = 'Last Payment Receipt Date';                        ToolTip = 'Specifies the date of the last payment received from the customer.';                        Importance = Additional;                    }                    field(LastPaymentAmount; LastPaymentAmount)                    {                        ApplicationArea = Basic, Suite;                        Caption = 'Last Payment Amount';                        ToolTip = 'Specifies the amount of the last payment received from the customer.';                        Importance = Additional;                        AutoFormatType = 1;                        AutoFormatExpression = '';                    }                    field(LastPaymentOnTime; LastPaymentOnTime)                    {                        ApplicationArea = Basic, Suite;                        Caption = 'Last Payment On Time';                        ToolTip = 'Specifies whether the last payment was applied before the due date.';                        Importance = Additional;                    }                }                group("Sales This Year")                {                    Caption = 'Sales This Year';                    field(AmountOnPostedInvoices; AmountOnPostedInvoices)                    {                        ApplicationArea = Basic, Suite;                        AutoFormatType = 1;                        AutoFormatExpression = '';                        CaptionClass = StrSubstNo(PostedInvoicesMsg, Format(NoPostedInvoices));                        ToolTip = 'Specifies your sales to the customer in the current fiscal year based on posted sales invoices. The figure in parenthesis Specifies the number of posted sales invoices.';                        trigger OnDrillDown()                        begin                            CustomerMgt.DrillDownOnPostedInvoices(Rec."No.")                        end;                    }                    field(AmountOnCrMemo; AmountOnPostedCrMemos)                    {                        ApplicationArea = Basic, Suite;                        AutoFormatType = 1;                        AutoFormatExpression = '';                        CaptionClass = StrSubstNo(CreditMemosMsg, Format(NoPostedCrMemos));                        ToolTip = 'Specifies your expected refunds to the customer in the current fiscal year based on posted sales credit memos. The figure in parenthesis shows the number of posted sales credit memos.';                        trigger OnDrillDown()                        begin                            CustomerMgt.DrillDownOnPostedCrMemo(Rec."No.")                        end;                    }                    field(AmountOnOutstandingInvoices; AmountOnOutstandingInvoices)                    {                        ApplicationArea = Basic, Suite;                        AutoFormatType = 1;                        AutoFormatExpression = '';                        CaptionClass = StrSubstNo(OutstandingInvoicesMsg, Format(NoOutstandingInvoices));                        ToolTip = 'Specifies your expected sales to the customer in the current fiscal year based on ongoing sales invoices. The figure in parenthesis shows the number of ongoing sales invoices.';                        trigger OnDrillDown()                        begin                            CustomerMgt.DrillDownOnUnpostedInvoices(Rec."No.")                        end;                    }                    field(AmountOnOutstandingCrMemos; AmountOnOutstandingCrMemos)                    {                        ApplicationArea = Basic, Suite;                        AutoFormatType = 1;                        AutoFormatExpression = '';                        CaptionClass = StrSubstNo(OutstandingCrMemosMsg, Format(NoOutstandingCrMemos));                        ToolTip = 'Specifies your refunds to the customer in the current fiscal year based on ongoing sales credit memos. The figure in parenthesis shows the number of ongoing sales credit memos.';                        trigger OnDrillDown()                        begin                            CustomerMgt.DrillDownOnUnpostedCrMemos(Rec."No.")                        end;                    }                    field(Totals; Totals)                    {                        ApplicationArea = Basic, Suite;                        AutoFormatType = 1;                        AutoFormatExpression = '';                        Caption = 'Total Sales';                        Style = Strong;                        StyleExpr = true;                        ToolTip = 'Specifies your total sales turnover with the customer in the current fiscal year. It is calculated from amounts excluding VAT on all completed and open invoices and credit memos.';                    }                    field(CustInvDiscAmountLCY; CustInvDiscAmountLCY)                    {                        ApplicationArea = Basic, Suite;                        AutoFormatType = 1;                        AutoFormatExpression = '';                        Caption = 'Invoice Discounts';                        ToolTip = 'Specifies the total of all invoice discounts that you have granted to the customer in the current fiscal year.';                    }                }                group(Interactions)                {                    Caption = 'Interactions';                    field(InteractionCount; InteractionCount)                    {                        ApplicationArea = Basic, Suite;                        Caption = 'Interactions';                        ToolTip = 'Specifies the number of interactions that you have had with the customer in the current fiscal year.';                        Importance = Additional;                    }                    field(LastInteractionDate; LastInteractionDate)                    {                        ApplicationArea = Basic, Suite;                        Caption = 'Last Interaction Date';                        ToolTip = 'Specifies the date when you last had an interaction with the customer.';                        Importance = Additional;                    }                    field(LastInteractionType; LastInteractionType)                    {                        ApplicationArea = Basic, Suite;                        Caption = 'Last Interaction Type';                        ToolTip = 'Specifies the type of the last interaction that you had with the customer.';                        Importance = Additional;                    }                    field(MostFrequentInteractionType; MostFrequentInteractionType)                    {                        ApplicationArea = Basic, Suite;                        Caption = 'Most Frequent Interaction Type';                        ToolTip = 'Specifies the type of interaction that you have most frequently with the customer in the current fiscal year.';                        Importance = Additional;                    }                }                part(AgedAccReceivableChart; "Aged Acc. Receivable Chart")                {                    ApplicationArea = Basic, Suite;                    SubPageLink = "No." = field("No.");                }            }        }        area(factboxes)        {            part(Control149; "Customer Picture")            {                ApplicationArea = Basic, Suite;                SubPageLink = "No." = field("No.");                Visible = not IsOfficeAddin;            }            part("Attached Documents List"; "Doc. Attachment List Factbox")            {                ApplicationArea = All;                Caption = 'Documents';                UpdatePropagation = Both;                SubPageLink = "Table ID" = const(Database::Customer),                              "No." = field("No.");            }            part(Details; "Office Customer Details")            {                ApplicationArea = All;                Caption = 'Details';                SubPageLink = "No." = field("No.");                Visible = IsOfficeAddin;            }            part(AgedAccReceivableChart2; "Aged Acc. Receivable Chart")            {                ApplicationArea = All;                SubPageLink = "No." = field("No.");                Visible = IsOfficeAddin;            }            part(Control39; "CRM Statistics FactBox")            {                ApplicationArea = All;                SubPageLink = "No." = field("No.");                Visible = CRMIsCoupledToRecord;            }            part(SalesHistSelltoFactBox; "Sales Hist. Sell-to FactBox")            {                ApplicationArea = Basic, Suite;                SubPageLink = "No." = field("No."),                              "Currency Filter" = field("Currency Filter"),                              "Date Filter" = field("Date Filter"),                              "Global Dimension 1 Filter" = field("Global Dimension 1 Filter"),                              "Global Dimension 2 Filter" = field("Global Dimension 2 Filter");            }            part(SalesHistBilltoFactBox; "Sales Hist. Bill-to FactBox")            {                ApplicationArea = All;                SubPageLink = "No." = field("No."),                              "Currency Filter" = field("Currency Filter"),                              "Date Filter" = field("Date Filter"),                              "Global Dimension 1 Filter" = field("Global Dimension 1 Filter"),                              "Global Dimension 2 Filter" = field("Global Dimension 2 Filter");                Visible = false;            }            part(CustomerStatisticsFactBox; "Customer Statistics FactBox")            {                ApplicationArea = Basic, Suite;                SubPageLink = "No." = field("No."),                              "Currency Filter" = field("Currency Filter"),                              "Date Filter" = field("Date Filter"),                              "Global Dimension 1 Filter" = field("Global Dimension 1 Filter"),                              "Global Dimension 2 Filter" = field("Global Dimension 2 Filter");            }            part(Control1905532107; "Dimensions FactBox")            {                ApplicationArea = Basic, Suite;                SubPageLink = "Table ID" = const(18),                              "No." = field("No.");            }            part(WorkflowStatus; "Workflow Status FactBox")            {                ApplicationArea = Suite;                Editable = false;                Enabled = false;                ShowFilter = false;                Visible = ShowWorkflowStatus;            }            systempart(Control1900383207; Links)            {                ApplicationArea = RecordLinks;            }            systempart(Control1905767507; Notes)            {                ApplicationArea = Notes;            }        }    }    actions    {        area(navigation)        {            group("&Customer")            {                Caption = '&Customer';                Image = Customer;                action(Dimensions)                {                    ApplicationArea = Dimensions;                    Caption = 'Dimensions';                    Image = Dimensions;                    RunObject = Page "Default Dimensions";                    RunPageLink = "Table ID" = const(18),                                  "No." = field("No.");                    ShortCutKey = 'Alt+D';                    ToolTip = 'View or edit dimensions, such as area, project, or department, that you can assign to sales and purchase documents to distribute costs and analyze transaction history.';                }                action("Bank Accounts")                {                    ApplicationArea = Basic, Suite;                    Caption = 'Bank Accounts';                    Image = BankAccount;                    RunObject = Page "Customer Bank Account List";                    RunPageLink = "Customer No." = field("No.");                    ToolTip = 'View or set up the customer''s bank accounts. You can set up any number of bank accounts for each customer.';                }                action("Direct Debit Mandates")                {                    ApplicationArea = Basic, Suite;                    Caption = 'Direct Debit Mandates';                    Image = MakeAgreement;                    RunObject = Page "SEPA Direct Debit Mandates";                    RunPageLink = "Customer No." = field("No.");                    ToolTip = 'View the direct-debit mandates that reflect agreements with customers to collect invoice payments from their bank account.';                }                action(ShipToAddresses)                {                    ApplicationArea = Basic, Suite;                    Caption = 'Ship-&to Addresses';                    Image = ShipAddress;                    RunObject = Page "Ship-to Address List";                    RunPageLink = "Customer No." = field("No.");                    ToolTip = 'View or edit alternate shipping addresses where the customer wants items delivered if different from the regular address.';                }                action(AlternativeVATRegistration)                {                    ApplicationArea = VAT;                    Caption = 'Alternative VAT Registration';                    Image = VATPostingSetup;                    RunObject = Page "Alt. Cust. VAT Reg.";                    RunPageLink = "Customer No." = field("No.");                    ToolTip = 'View or set up an alternative VAT registration number for the customer.';                }                action(Contact)                {                    AccessByPermission = TableData Contact = R;                    ApplicationArea = Basic, Suite;                    Caption = 'C&ontact';                    Image = ContactPerson;                    ToolTip = 'View or edit detailed information about the contact person at the customer.';                    trigger OnAction()                    begin                        Rec.ShowContact();                    end;                }                action("Item References")                {                    AccessByPermission = TableData "Item Reference" = R;                    ApplicationArea = Suite, ItemReferences;                    Caption = 'Item References';                    Image = Change;                    RunObject = Page "Item References";                    RunPageLink = "Reference Type" = const(Customer),                                  "Reference Type No." = field("No.");                    RunPageView = sorting("Reference Type", "Reference Type No.");                    ToolTip = 'Set up the customer''s own identification of items that you sell to the customer. Item references to the customer''s item number means that the item number is automatically shown on sales documents instead of the number that you use.';                }                action("Co&mments")                {                    ApplicationArea = Comments;                    Caption = 'Co&mments';                    Image = ViewComments;                    RunObject = Page "Comment Sheet";                    RunPageLink = "Table Name" = const(Customer),                                  "No." = field("No.");                    ToolTip = 'View or add comments for the record.';                }                action(ApprovalEntries)                {                    AccessByPermission = TableData "Approval Entry" = R;                    ApplicationArea = Suite;                    Caption = 'Approvals';                    Image = Approvals;                    ToolTip = 'View a list of the records that are waiting to be approved. For example, you can see who requested the record to be approved, when it was sent, and when it is due to be approved.';                    trigger OnAction()                    begin                        ApprovalsMgmt.OpenApprovalEntriesPage(Rec.RecordId);                    end;                }                action(Attachments)                {                    ApplicationArea = All;                    Caption = 'Attachments';                    Image = Attach;                    ToolTip = 'Add a file as an attachment. You can attach images as well as documents.';                    trigger OnAction()                    var                        DocumentAttachmentDetails: Page "Document Attachment Details";                        RecRef: RecordRef;                    begin                        RecRef.GetTable(Rec);                        DocumentAttachmentDetails.OpenForRecRef(RecRef);                        DocumentAttachmentDetails.RunModal();                    end;                }                action(CustomerReportSelections)                {                    ApplicationArea = Basic, Suite;                    Caption = 'Document Layouts';                    Image = Quote;                    ToolTip = 'Set up a layout for different types of documents such as invoices, quotes, and credit memos.';                    trigger OnAction()                    var                        CustomReportSelection: Record "Custom Report Selection";                    begin                        CustomReportSelection.SetRange("Source Type", DATABASE::Customer);                        CustomReportSelection.SetRange("Source No.", Rec."No.");                        PAGE.RunModal(PAGE::"Customer Report Selections", CustomReportSelection);                    end;                }            }            group(ActionGroupCRM)            {                Caption = 'Dataverse';                Enabled = (BlockedFilterApplied and (Rec.Blocked = Rec.Blocked::" ")) or not BlockedFilterApplied;                Visible = CRMIntegrationEnabled or CDSIntegrationEnabled;                action(CRMGotoAccount)                {                    ApplicationArea = Suite;                    Caption = 'Account';                    Image = CoupledCustomer;                    ToolTip = 'Open the coupled Dataverse account.';                    Visible = CRMIntegrationEnabled or CDSIntegrationEnabled;                    trigger OnAction()                    var                        CRMIntegrationManagement: Codeunit "CRM Integration Management";                    begin                        CRMIntegrationManagement.ShowCRMEntityFromRecordID(Rec.RecordId);                    end;                }                action(CRMSynchronizeNow)                {                    AccessByPermission = TableData "CRM Integration Record" = IM;                    ApplicationArea = Suite;                    Caption = 'Synchronize';                    Image = Refresh;                    ToolTip = 'Send or get updated data to or from Dataverse.';                    Visible = CRMIntegrationEnabled or CDSIntegrationEnabled;                    trigger OnAction()                    var                        CRMIntegrationManagement: Codeunit "CRM Integration Management";                    begin                        CRMIntegrationManagement.UpdateOneNow(Rec.RecordId);                    end;                }                action(UpdateStatisticsInCRM)                {                    ApplicationArea = Suite;                    Caption = 'Update Account Statistics';                    Enabled = CRMIsCoupledToRecord;                    Image = UpdateXML;                    ToolTip = 'Send customer statistics data to Dataverse to update the Account Statistics FactBox.';                    Visible = CRMIntegrationEnabled;                    trigger OnAction()                    var                        CRMIntegrationManagement: Codeunit "CRM Integration Management";                    begin                        CRMIntegrationManagement.CreateOrUpdateCRMAccountStatistics(Rec);                    end;                }                group(Coupling)                {                    Caption = 'Coupling', Comment = 'Coupling is a noun';                    Image = LinkAccount;                    ToolTip = 'Create, change, or delete a coupling between the Business Central record and a Dataverse record.';                    action(ManageCRMCoupling)                    {                        AccessByPermission = TableData "CRM Integration Record" = IM;                        ApplicationArea = Suite;                        Caption = 'Set Up Coupling';                        Image = LinkAccount;                        ToolTip = 'Create or modify the coupling to a Dataverse account.';                        Visible = CRMIntegrationEnabled or CDSIntegrationEnabled;                        trigger OnAction()                        var                            CRMIntegrationManagement: Codeunit "CRM Integration Management";                        begin                            CRMIntegrationManagement.DefineCoupling(Rec.RecordId);                        end;                    }                    action(DeleteCRMCoupling)                    {                        AccessByPermission = TableData "CRM Integration Record" = D;                        ApplicationArea = Suite;                        Caption = 'Delete Coupling';                        Enabled = CRMIsCoupledToRecord;                        Image = UnLinkAccount;                        ToolTip = 'Delete the coupling to a Dataverse account.';                        Visible = CRMIntegrationEnabled or CDSIntegrationEnabled;                        trigger OnAction()                        var                            CRMCouplingManagement: Codeunit "CRM Coupling Management";                        begin                            CRMCouplingManagement.RemoveCoupling(Rec.RecordId);                        end;                    }                }                action(ShowLog)                {                    ApplicationArea = Suite;                    Caption = 'Synchronization Log';                    Image = Log;                    ToolTip = 'View integration synchronization jobs for the customer table.';                    Visible = CRMIntegrationEnabled or CDSIntegrationEnabled;                    trigger OnAction()                    var                        CRMIntegrationManagement: Codeunit "CRM Integration Management";                    begin                        CRMIntegrationManagement.ShowLog(Rec.RecordId);                    end;                }            }            group(History)            {                Caption = 'History';                Image = History;                action("Ledger E&ntries")                {                    ApplicationArea = Basic, Suite;                    Caption = 'Ledger E&ntries';                    Image = CustomerLedger;                    RunObject = Page "Customer Ledger Entries";                    RunPageLink = "Customer No." = field("No.");                    RunPageView = sorting("Customer No.")                                  order(descending);                    ShortCutKey = 'Ctrl+F7';                    ToolTip = 'View the history of transactions that have been posted for the selected record.';                }                action(Action76)                {                    ApplicationArea = Suite;                    Caption = 'Statistics';                    Image = Statistics;                    RunObject = Page "Customer Statistics";                    RunPageLink = "No." = field("No."),                                  "Date Filter" = field("Date Filter"),                                  "Global Dimension 1 Filter" = field("Global Dimension 1 Filter"),                                  "Global Dimension 2 Filter" = field("Global Dimension 2 Filter");                    ShortCutKey = 'F7';                    ToolTip = 'View statistical information, such as the value of posted entries, for the record.';                }                action("S&ales")                {                    ApplicationArea = Basic, Suite;                    Caption = 'S&ales';                    Image = Sales;                    RunObject = Page "Customer Sales";                    RunPageLink = "No." = field("No."),                                  "Global Dimension 1 Filter" = field("Global Dimension 1 Filter"),                                  "Global Dimension 2 Filter" = field("Global Dimension 2 Filter");                    ToolTip = 'View a summary of customer ledger entries. You select the time interval in the View by field. The Period column on the left contains a series of dates that are determined by the time interval you have selected.';                }                action("Entry Statistics")                {                    ApplicationArea = Suite;                    Caption = 'Entry Statistics';                    Image = EntryStatistics;                    RunObject = Page "Customer Entry Statistics";                    RunPageLink = "No." = field("No."),                                  "Date Filter" = field("Date Filter"),                                  "Global Dimension 1 Filter" = field("Global Dimension 1 Filter"),                                  "Global Dimension 2 Filter" = field("Global Dimension 2 Filter");                    ToolTip = 'View entry statistics for the record.';                }                action("Statistics by C&urrencies")                {                    ApplicationArea = Suite;                    Caption = 'Statistics by C&urrencies';                    Image = Currencies;                    RunObject = Page "Cust. Stats. by Curr. Lines";                    RunPageLink = "Customer Filter" = field("No."),                                  "Global Dimension 1 Filter" = field("Global Dimension 1 Filter"),                                  "Global Dimension 2 Filter" = field("Global Dimension 2 Filter"),                                  "Date Filter" = field("Date Filter");                    ToolTip = 'View statistics for customers that use multiple currencies.';                }                action("Item &Tracking Entries")                {                    ApplicationArea = ItemTracking;                    Caption = 'Item &Tracking Entries';                    Image = ItemTrackingLedger;                    ToolTip = 'View serial, lot or package numbers that are assigned to items.';                    trigger OnAction()                    var                        ItemTrackingDocMgt: Codeunit "Item Tracking Doc. Management";                    begin                        ItemTrackingDocMgt.ShowItemTrackingForEntity(1, Rec."No.", '', '', '');                    end;                }                action("Sent Emails")                {                    ApplicationArea = Basic, Suite;                    Caption = 'Sent Emails';                    Image = ShowList;                    ToolTip = 'View a list of emails that you have sent to this customer.';                    trigger OnAction()                    var                        Email: Codeunit Email;                    begin                        Email.OpenSentEmails(Database::Customer, Rec.SystemId);                    end;                }                separator(Action140)                {                }            }            group("Prices and Discounts")            {                Caption = 'Prices & Discounts';                action("Invoice &Discounts")                {                    ApplicationArea = Basic, Suite;                    Caption = 'Invoice &Discounts';                    Image = CalculateInvoiceDiscount;                    //The property 'PromotedCategory' can only be set if the property 'Promoted' is set to 'true'                    //PromotedCategory = Category7;                    RunObject = Page "Cust. Invoice Discounts";                    RunPageLink = Code = field("Invoice Disc. Code");                    ToolTip = 'Set up different discounts that are applied to invoices for the customer. An invoice discount is automatically granted to the customer when the total on a sales invoice exceeds a certain amount.';                }                action(PriceLists)                {                    ApplicationArea = Basic, Suite;                    Caption = 'Sales Price Lists';                    Image = Price;                    Visible = ExtendedPriceEnabled;                    ToolTip = 'View or set up sales price lists for products that you sell to the customer. A product price is automatically granted on invoice lines when the specified criteria are met, such as customer, quantity, or ending date.';                    trigger OnAction()                    var                        PriceUXManagement: Codeunit "Price UX Management";                    begin                        PriceUXManagement.ShowPriceLists(Rec, Enum::"Price Amount Type"::Any);                    end;                }                action(PriceLines)                {                    AccessByPermission = TableData "Sales Price Access" = R;                    ApplicationArea = Basic, Suite;                    Caption = 'Sales Prices';                    Image = Price;                    Scope = Repeater;                    Visible = ExtendedPriceEnabled;                    ToolTip = 'View or set up sales price lines for products that you sell to the customer. A product price is automatically granted on invoice lines when the specified criteria are met, such as customer, quantity, or ending date.';                    trigger OnAction()                    var                        PriceSource: Record "Price Source";                        PriceUXManagement: Codeunit "Price UX Management";                    begin                        Rec.ToPriceSource(PriceSource);                        PriceUXManagement.ShowPriceListLines(PriceSource, Enum::"Price Amount Type"::Price);                    end;                }                action(DiscountLines)                {                    AccessByPermission = TableData "Sales Discount Access" = R;                    ApplicationArea = Basic, Suite;                    Caption = 'Sales Discounts';                    Image = LineDiscount;                    Scope = Repeater;                    Visible = ExtendedPriceEnabled;                    ToolTip = 'View or set up different discounts for products that you sell to the customer. A product line discount is automatically granted on invoice lines when the specified criteria are met, such as customer, quantity, or ending date.';                    trigger OnAction()                    var                        PriceSource: Record "Price Source";                        PriceUXManagement: Codeunit "Price UX Management";                    begin                        Rec.ToPriceSource(PriceSource);                        PriceUXManagement.ShowPriceListLines(PriceSource, Enum::"Price Amount Type"::Discount);                    end;                }                action(PriceListsDiscounts)                {                    ApplicationArea = Basic, Suite;                    Caption = 'Price Lists (Discounts)';                    Image = LineDiscount;                    Visible = false;                    ToolTip = 'View or set up different discounts for products that you sell to the customer. A product line discount is automatically granted on invoice lines when the specified criteria are met, such as customer, quantity, or ending date.';                    trigger OnAction()                    var                        PriceUXManagement: Codeunit "Price UX Management";                        AmountType: Enum "Price Amount Type";                    begin                        PriceUXManagement.ShowPriceLists(Rec, AmountType::Discount);                    end;                }                action(Prices)                {                    ApplicationArea = Basic, Suite;                    Caption = 'Prices';                    Image = Price;                    Visible = not ExtendedPriceEnabled;                    ToolTip = 'View or set up different prices for items that you sell to the customer. An item price is automatically granted on invoice lines when the specified criteria are met, such as customer, quantity, or ending date.';                    trigger OnAction()                    var                        SalesPrice: Record "Sales Price";                    begin                        SalesPrice.SetCurrentKey("Sales Type", "Sales Code");                        SalesPrice.SetRange("Sales Type", SalesPrice."Sales Type"::Customer);                        SalesPrice.SetRange("Sales Code", Rec."No.");                        Page.Run(Page::"Sales Prices", SalesPrice);                    end;                }                action("Line Discounts")                {                    ApplicationArea = Basic, Suite;                    Caption = 'Line Discounts';                    Image = LineDiscount;                    Visible = not ExtendedPriceEnabled;                    ToolTip = 'View or set up different discounts for items that you sell to the customer. An item discount is automatically granted on invoice lines when the specified criteria are met, such as customer, quantity, or ending date.';                    trigger OnAction()                    var                        SalesLineDiscount: Record "Sales Line Discount";                    begin                        SalesLineDiscount.SetCurrentKey("Sales Type", "Sales Code");                        SalesLineDiscount.SetRange("Sales Type", SalesLineDiscount."Sales Type"::Customer);                        SalesLineDiscount.SetRange("Sales Code", Rec."No.");                        Page.Run(Page::"Sales Line Discounts", SalesLineDiscount);                    end;                }                action("Prices and Discounts Overview")                {                    ApplicationArea = Basic, Suite;                    Caption = 'Prices & Discounts Overview';                    Image = PriceWorksheet;                    Visible = not ExtendedPriceEnabled;                    ToolTip = 'View all the sales prices and line discounts that you grant for this customer when certain criteria are met, such as quantity, or ending date.';                    trigger OnAction()                    var                        SalesPriceAndLineDiscounts: Page "Sales Price and Line Discounts";                    begin                        SalesPriceAndLineDiscounts.InitPage(false);                        SalesPriceAndLineDiscounts.LoadCustomer(Rec);                        SalesPriceAndLineDiscounts.RunModal();                    end;                }            }            group(Action82)            {                Caption = 'S&ales';                Image = Sales;                action("Prepa&yment Percentages")                {                    ApplicationArea = Prepayments;                    Caption = 'Prepa&yment Percentages';                    Image = PrepaymentPercentages;                    RunObject = Page "Sales Prepayment Percentages";                    RunPageLink = "Sales Type" = const(Customer),                                  "Sales Code" = field("No.");                    RunPageView = sorting("Sales Type", "Sales Code");                    ToolTip = 'View or edit the percentages of the price that can be paid as a prepayment. ';                }                action("Recurring Sales Lines")                {                    ApplicationArea = Suite;                    Caption = 'Recurring Sales Lines';                    Ellipsis = true;                    Image = CustomerCode;                    //The property 'PromotedCategory' can only be set if the property 'Promoted' is set to 'true'                    //PromotedCategory = Category5;                    //The property 'PromotedIsBig' can only be set if the property 'Promoted' is set to 'true'                    //PromotedIsBig = true;                    RunObject = Page "Standard Customer Sales Codes";                    RunPageLink = "Customer No." = field("No.");                    ToolTip = 'Set up recurring sales lines for the customer, such as a monthly replenishment order, that can quickly be inserted on a sales document for the customer.';                }            }            group(Documents)            {                Caption = 'Documents';                Image = Documents;                action(Quotes)                {                    ApplicationArea = Basic, Suite;                    Caption = 'Quotes';                    Image = Quote;                    RunObject = Page "Sales Quotes";                    RunPageLink = "Sell-to Customer No." = field("No.");                    RunPageView = sorting("Document Type", "Sell-to Customer No.");                    ToolTip = 'View a list of ongoing sales quotes for the customer.';                }                action(Invoices)                {                    ApplicationArea = Basic, Suite;                    Caption = 'Invoices';                    Image = Invoice;                    RunObject = Page "Sales Invoice List";                    RunPageLink = "Sell-to Customer No." = field("No.");                    RunPageView = sorting("Document Type", "Sell-to Customer No.");                    ToolTip = 'View a list of ongoing sales invoices for the customer.';                }                action(Orders)                {                    ApplicationArea = Basic, Suite;                    Caption = 'Orders';                    Image = Document;                    RunObject = Page "Sales Order List";                    RunPageLink = "Sell-to Customer No." = field("No.");                    RunPageView = sorting("Document Type", "Sell-to Customer No.");                    ToolTip = 'View a list of ongoing sales orders for the customer.';                }                action("Return Orders")                {                    ApplicationArea = SalesReturnOrder;                    Caption = 'Return Orders';                    Image = ReturnOrder;                    RunObject = Page "Sales Return Order List";                    RunPageLink = "Sell-to Customer No." = field("No.");                    RunPageView = sorting("Document Type", "Sell-to Customer No.");                    ToolTip = 'Open the list of ongoing return orders.';                }                group("Issued Documents")                {                    Caption = 'Issued Documents';                    Image = Documents;                    action("Issued &Reminders")                    {                        ApplicationArea = Suite;                        Caption = 'Issued &Reminders';                        Image = OrderReminder;                        RunObject = Page "Issued Reminder List";                        RunPageLink = "Customer No." = field("No.");                        RunPageView = sorting("Customer No.", "Posting Date");                        ToolTip = 'View the reminders that you have sent to the customer.';                    }                    action("Issued &Finance Charge Memos")                    {                        ApplicationArea = Suite;                        Caption = 'Issued &Finance Charge Memos';                        Image = FinChargeMemo;                        RunObject = Page "Issued Fin. Charge Memo List";                        RunPageLink = "Customer No." = field("No.");                        RunPageView = sorting("Customer No.", "Posting Date");                        ToolTip = 'View the finance charge memos that you have sent to the customer.';                    }                }                action("Blanket Orders")                {                    ApplicationArea = Suite;                    Caption = 'Blanket Orders';                    Image = BlanketOrder;                    RunObject = Page "Blanket Sales Orders";                    RunPageLink = "Sell-to Customer No." = field("No.");                    RunPageView = sorting("Document Type", "Sell-to Customer No.");                    ToolTip = 'Open the list of ongoing blanket orders.';                }                action("&Jobs")                {                    ApplicationArea = Jobs;                    Caption = '&Projects';                    Image = Job;                    RunObject = Page "Job List";                    RunPageLink = "Bill-to Customer No." = field("No.");                    RunPageView = sorting("Bill-to Customer No.");                    ToolTip = 'Open the list of ongoing projects.';                }            }        }        area(creation)        {            action(NewBlanketSalesOrder)            {                AccessByPermission = TableData "Sales Header" = RIM;                ApplicationArea = Suite;                Caption = 'Blanket Sales Order';                Image = BlanketOrder;                //The property 'PromotedCategory' can only be set if the property 'Promoted' is set to 'true'                //PromotedCategory = Category4;                RunObject = Page "Blanket Sales Order";                RunPageLink = "Sell-to Customer No." = field("No.");                RunPageMode = Create;                ToolTip = 'Create a blanket sales order for the customer.';            }            action(NewSalesQuote)            {                AccessByPermission = TableData "Sales Header" = RIM;                ApplicationArea = Basic, Suite;                Caption = 'Sales Quote';                Image = NewSalesQuote;                RunObject = Page "Sales Quote";                RunPageLink = "Sell-to Customer No." = field("No.");                RunPageMode = Create;                ToolTip = 'Offer items or services to a customer.';                Visible = not IsOfficeAddin;            }            action(NewSalesInvoice)            {                AccessByPermission = TableData "Sales Header" = RIM;                ApplicationArea = Basic, Suite;                Caption = 'Sales Invoice';                Image = NewSalesInvoice;                RunObject = Page "Sales Invoice";                RunPageLink = "Sell-to Customer No." = field("No.");                RunPageMode = Create;                ToolTip = 'Create a sales invoice for the customer.';                Visible = not IsOfficeAddin;            }            action(NewSalesOrder)            {                AccessByPermission = TableData "Sales Header" = RIM;                ApplicationArea = Basic, Suite;                Caption = 'Sales Order';                Image = Document;                RunObject = Page "Sales Order";                RunPageLink = "Sell-to Customer No." = field("No.");                RunPageMode = Create;                ToolTip = 'Create a sales order for the customer.';                Visible = not IsOfficeAddin;            }            action(NewSalesCreditMemo)            {                AccessByPermission = TableData "Sales Header" = RIM;                ApplicationArea = Basic, Suite;                Caption = 'Sales Credit Memo';                Image = CreditMemo;                RunObject = Page "Sales Credit Memo";                RunPageLink = "Sell-to Customer No." = field("No.");                RunPageMode = Create;                ToolTip = 'Create a new sales credit memo to revert a posted sales invoice.';                Visible = not IsOfficeAddin;            }            action(NewSalesQuoteAddin)            {                AccessByPermission = TableData "Sales Header" = RIM;                ApplicationArea = Basic, Suite;                Caption = 'Sales Quote';                Image = NewSalesQuote;                ToolTip = 'Offer items or services to a customer.';                Visible = IsOfficeAddin;                trigger OnAction()                begin                    Rec.CreateAndShowNewQuote();                end;            }            action(NewSalesInvoiceAddin)            {                AccessByPermission = TableData "Sales Header" = RIM;                ApplicationArea = Basic, Suite;                Caption = 'Sales Invoice';                Image = NewSalesInvoice;                ToolTip = 'Create a sales invoice for the customer.';                Visible = IsOfficeAddin;                trigger OnAction()                begin                    Rec.CreateAndShowNewInvoice();                end;            }            action(NewSalesOrderAddin)            {                AccessByPermission = TableData "Sales Header" = RIM;                ApplicationArea = Basic, Suite;                Caption = 'Sales Order';                Image = Document;                ToolTip = 'Create a sales order for the customer.';                Visible = IsOfficeAddin;                trigger OnAction()                begin                    Rec.CreateAndShowNewOrder();                end;            }            action(NewSalesCreditMemoAddin)            {                AccessByPermission = TableData "Sales Header" = RIM;                ApplicationArea = Basic, Suite;                Caption = 'Sales Credit Memo';                Image = CreditMemo;                ToolTip = 'Create a new sales credit memo to revert a posted sales invoice.';                Visible = IsOfficeAddin;                trigger OnAction()                begin                    Rec.CreateAndShowNewCreditMemo();                end;            }            action(NewSalesReturnOrder)            {                AccessByPermission = TableData "Sales Header" = RIM;                ApplicationArea = SalesReturnOrder;                Caption = 'Sales Return Order';                Image = ReturnOrder;                //The property 'PromotedCategory' can only be set if the property 'Promoted' is set to 'true'                //PromotedCategory = Category4;                RunObject = Page "Sales Return Order";                RunPageLink = "Sell-to Customer No." = field("No.");                RunPageMode = Create;                ToolTip = 'Create a new sales return order for items or services.';            }            action(NewReminder)            {                AccessByPermission = TableData "Reminder Header" = RIM;                ApplicationArea = Suite;                Caption = 'Reminder';                Image = Reminder;                RunObject = Page Reminder;                RunPageLink = "Customer No." = field("No.");                RunPageMode = Create;                ToolTip = 'Create a new reminder for the customer.';            }            action(NewFinanceChargeMemo)            {                AccessByPermission = TableData "Finance Charge Memo Header" = RIM;                ApplicationArea = Suite;                Caption = 'Finance Charge Memo';                Image = FinChargeMemo;                //The property 'PromotedCategory' can only be set if the property 'Promoted' is set to 'true'                //PromotedCategory = Category4;                RunObject = Page "Finance Charge Memo";                RunPageLink = "Customer No." = field("No.");                RunPageMode = Create;                ToolTip = 'Create a new finance charge memo.';            }        }        area(processing)        {            group(Approval)            {                Caption = 'Approval';                Visible = OpenApprovalEntriesExistCurrUser;                action(Approve)                {                    ApplicationArea = All;                    Caption = 'Approve';                    Image = Approve;                    ToolTip = 'Approve the requested changes.';                    Visible = OpenApprovalEntriesExistCurrUser;                    trigger OnAction()                    var                        ApprovalsMgmt: Codeunit "Approvals Mgmt.";                    begin                        ApprovalsMgmt.ApproveRecordApprovalRequest(Rec.RecordId);                    end;                }                action(Reject)                {                    ApplicationArea = All;                    Caption = 'Reject';                    Image = Reject;                    ToolTip = 'Reject the approval request.';                    Visible = OpenApprovalEntriesExistCurrUser;                    trigger OnAction()                    var                        ApprovalsMgmt: Codeunit "Approvals Mgmt.";                    begin                        ApprovalsMgmt.RejectRecordApprovalRequest(Rec.RecordId);                    end;                }                action(Delegate)                {                    ApplicationArea = All;                    Caption = 'Delegate';                    Image = Delegate;                    ToolTip = 'Delegate the approval to a substitute approver.';                    Visible = OpenApprovalEntriesExistCurrUser;                    trigger OnAction()                    var                        ApprovalsMgmt: Codeunit "Approvals Mgmt.";                    begin                        ApprovalsMgmt.DelegateRecordApprovalRequest(Rec.RecordId);                    end;                }                action(Comment)                {                    ApplicationArea = All;                    Caption = 'Comments';                    Image = ViewComments;                    ToolTip = 'View or add comments for the record.';                    Visible = OpenApprovalEntriesExistCurrUser;                    trigger OnAction()                    var                        ApprovalsMgmt: Codeunit "Approvals Mgmt.";                    begin                        ApprovalsMgmt.GetApprovalComment(Rec);                    end;                }            }            group("Request Approval")            {                Caption = 'Request Approval';                Image = SendApprovalRequest;                action(SendApprovalRequest)                {                    ApplicationArea = Basic, Suite;                    Caption = 'Send A&pproval Request';                    Enabled = (not OpenApprovalEntriesExist) and EnabledApprovalWorkflowsExist and CanRequestApprovalForFlow;                    Image = SendApprovalRequest;                    ToolTip = 'Request approval to change the record.';                    trigger OnAction()                    var                        ApprovalsMgmt: Codeunit "Approvals Mgmt.";                    begin                        if ApprovalsMgmt.CheckCustomerApprovalsWorkflowEnabled(Rec) then                            ApprovalsMgmt.OnSendCustomerForApproval(Rec);                        SetWorkFlowEnabled();                    end;                }                action(CancelApprovalRequest)                {                    ApplicationArea = Basic, Suite;                    Caption = 'Cancel Approval Re&quest';                    Enabled = CanCancelApprovalForRecord or CanCancelApprovalForFlow;                    Image = CancelApprovalRequest;                    ToolTip = 'Cancel the approval request.';                    trigger OnAction()                    var                        ApprovalsMgmt: Codeunit "Approvals Mgmt.";                        WorkflowWebhookManagement: Codeunit "Workflow Webhook Management";                    begin                        ApprovalsMgmt.OnCancelCustomerApprovalRequest(Rec);                        WorkflowWebhookManagement.FindAndCancel(Rec.RecordId);                    end;                }                group(Flow)                {                    Caption = 'Power Automate';                    customaction(CreateFlowFromTemplate)                    {                        ApplicationArea = Basic, Suite;                        Caption = 'Create approval flow';                        ToolTip = 'Create a new flow in Power Automate from a list of relevant flow templates.';                        Visible = IsSaaS and IsPowerAutomatePrivacyNoticeApproved;                        CustomActionType = FlowTemplateGallery;                        FlowTemplateCategoryName = 'd365bc_approval_customer';                    }                }            }            group(Workflow)            {                Caption = 'Workflow';                action(CreateApprovalWorkflow)                {                    ApplicationArea = Suite;                    Caption = 'Create Approval Workflow';                    Enabled = not EnabledApprovalWorkflowsExist;                    Image = CreateWorkflow;                    ToolTip = 'Set up an approval workflow for creating or changing customers, by going through a few pages that will guide you.';                    trigger OnAction()                    begin                        PAGE.RunModal(PAGE::"Cust. Approval WF Setup Wizard");                        SetWorkFlowEnabled();                    end;                }                action(ManageApprovalWorkflows)                {                    ApplicationArea = Suite;                    Caption = 'Manage Approval Workflows';                    Enabled = EnabledApprovalWorkflowsExist;                    Image = WorkflowSetup;                    ToolTip = 'View or edit existing approval workflows for creating or changing customers.';                    trigger OnAction()                    var                        WorkflowManagement: Codeunit "Workflow Management";                    begin                        WorkflowManagement.NavigateToWorkflows(DATABASE::Customer, WorkFlowEventFilter);                        SetWorkFlowEnabled();                    end;                }            }            group("F&unctions")            {                Caption = 'F&unctions';                Image = "Action";                action(Templates)                {                    ApplicationArea = Basic, Suite;                    Caption = 'Templates';                    Image = Template;                    //The property 'PromotedIsBig' can only be set if the property 'Promoted' is set to 'true'                    //PromotedIsBig = true;                    ToolTip = 'View or edit customer templates.';                    trigger OnAction()                    var                        CustomerTemplMgt: Codeunit "Customer Templ. Mgt.";                    begin                        CustomerTemplMgt.ShowTemplates();                    end;                }                action(ApplyTemplate)                {                    ApplicationArea = Basic, Suite;                    Caption = 'Apply Template';                    Image = ApplyTemplate;                    ToolTip = 'Apply a template to update the entity with your standard settings for a certain type of entity.';                    trigger OnAction()                    var                        CustomerTemplMgt: Codeunit "Customer Templ. Mgt.";                    begin                        CustomerTemplMgt.UpdateCustomerFromTemplate(Rec);                    end;                }                action(SaveAsTemplate)                {                    ApplicationArea = Basic, Suite;                    Caption = 'Save as Template';                    Image = Save;                    ToolTip = 'Save the customer card as a template that can be reused to create new customer cards. Customer templates contain preset information to help you fill fields on customer cards.';                    trigger OnAction()                    var                        CustomerTemplMgt: Codeunit "Customer Templ. Mgt.";                    begin                        CustomerTemplMgt.SaveAsTemplate(Rec);                    end;                }                action(MergeDuplicate)                {                    AccessByPermission = TableData "Merge Duplicates Buffer" = RIMD;                    ApplicationArea = Basic, Suite;                    Caption = 'Merge With';                    Ellipsis = true;                    Image = ItemSubstitution;                    ToolTip = 'Merge two customer records into one. Before merging, review which field values you want to keep or override. The merge action cannot be undone.';                    trigger OnAction()                    var                        TempMergeDuplicatesBuffer: Record "Merge Duplicates Buffer" temporary;                    begin                        TempMergeDuplicatesBuffer.Show(DATABASE::Customer, Rec."No.");                    end;                }            }            action("Post Cash Receipts")            {                ApplicationArea = Basic, Suite;                Caption = 'Post Cash Receipts';                Ellipsis = true;                Image = CashReceiptJournal;                //The property 'PromotedCategory' can only be set if the property 'Promoted' is set to 'true'                //PromotedCategory = Process;                RunObject = Page "Cash Receipt Journal";                ToolTip = 'Create a cash receipt journal line for the customer, for example, to post a payment receipt.';            }            action("Sales Journal")            {                ApplicationArea = Basic, Suite;                Caption = 'Sales Journal';                Image = Journals;                //The property 'PromotedCategory' can only be set if the property 'Promoted' is set to 'true'                //PromotedCategory = Process;                RunObject = Page "Sales Journal";                ToolTip = 'Post any sales transaction for the customer.';            }            action(PaymentRegistration)            {                ApplicationArea = Basic, Suite;                Caption = 'Register Customer Payments';                Image = Payment;                //The property 'PromotedCategory' can only be set if the property 'Promoted' is set to 'true'                //PromotedCategory = Process;                RunObject = Page "Payment Registration";                RunPageLink = "Source No." = field("No.");                ToolTip = 'Process your customer payments by matching amounts received on your bank account with the related unpaid sales invoices, and then post the payments.';            }            action(WordTemplate)            {                ApplicationArea = All;                Caption = 'Apply Word Template';                ToolTip = 'Apply a Word template on the selected records.';                Image = Word;                trigger OnAction()                var                    Customer: Record Customer;                    WordTemplateSelectionWizard: Page "Word Template Selection Wizard";                begin                    CurrPage.SetSelectionFilter(Customer);                    WordTemplateSelectionWizard.SetData(Customer);                    WordTemplateSelectionWizard.RunModal();                end;            }            action(Email)            {                ApplicationArea = All;                Caption = 'Send Email';                Image = Email;                ToolTip = 'Send an email to this customer.';                trigger OnAction()                var                    TempEmailItem: Record "Email Item" temporary;                    EmailScenario: Enum "Email Scenario";                begin                    TempEmailItem.AddSourceDocument(Database::Customer, Rec.SystemId);                    TempEmailitem."Send to" := Rec."E-Mail";                    TempEmailItem.Send(false, EmailScenario::Default);                end;            }        }        area(reporting)        {            action("Report Customer Detailed Aging")            {                ApplicationArea = Basic, Suite;                Caption = 'Customer Detailed Aging';                Image = "Report";                //The property 'PromotedCategory' can only be set if the property 'Promoted' is set to 'true'                //PromotedCategory = "Report";                ToolTip = 'View a detailed list of each customer''s total payments due, divided into three time periods. The report can be used to decide when to issue reminders, to evaluate a customer''s creditworthiness, or to prepare liquidity analyses.';                trigger OnAction()                begin                    RunReport(REPORT::"Customer Detailed Aging", Rec."No.");                end;            }            action("Report Customer - Labels")            {                ApplicationArea = Basic, Suite;                Caption = 'Customer - Labels';                Image = "Report";                //The property 'PromotedCategory' can only be set if the property 'Promoted' is set to 'true'                //PromotedCategory = Category9;                ToolTip = 'View mailing labels with the customers'' names and addresses.';                trigger OnAction()                begin                    RunReport(REPORT::"Customer - Labels", Rec."No.");                end;            }            action("Report Customer - Balance to Date")            {                ApplicationArea = Basic, Suite;                Caption = 'Customer - Balance to Date';                Image = "Report";                //The property 'PromotedCategory' can only be set if the property 'Promoted' is set to 'true'                //PromotedCategory = Category9;                ToolTip = 'View a list with customers'' payment history up until a certain date. You can use the report to extract your total sales income at the close of an accounting period or fiscal year.';                trigger OnAction()                begin                    RunReport(REPORT::"Customer - Balance to Date", Rec."No.");                end;            }            action("Report Statement")            {                ApplicationArea = Basic, Suite;                Caption = 'Statement';                Image = "Report";                ToolTip = 'View a list of a customer''s transactions for a selected period, for example, to send to the customer at the close of an accounting period. You can choose to have all overdue balances displayed regardless of the period specified, or you can choose to include an aging band.';                trigger OnAction()                var                    Customer: Record Customer;                    CustomReportSelection: Record "Custom Report Selection";                    ReportSelections: Record "Report Selections";                    CustomLayoutReporting: Codeunit "Custom Layout Reporting";                    RecRef: RecordRef;                begin                    RecRef.Open(Database::Customer);                    CustomLayoutReporting.SetOutputFileBaseName(StatementFileNameTxt);                    CustomReportSelection.SetRange(Usage, Enum::"Report Selection Usage"::"C.Statement");                    CustomReportSelection.SetRange("Source Type", Database::Customer);                    CustomReportSelection.SetRange("Source No.", Rec."No.");                    if CustomReportSelection.FindFirst() then                        CustomLayoutReporting.SetTableFilterForReportID(CustomReportSelection."Report ID", Rec."No.")                    else begin                        ReportSelections.SetRange(Usage, Enum::"Report Selection Usage"::"C.Statement");                        if ReportSelections.FindFirst() then                            CustomLayoutReporting.SetTableFilterForReportID(ReportSelections."Report ID", Rec."No.")                        else                            CustomLayoutReporting.SetTableFilterForReportID(Report::"Standard Statement", Rec."No.");                    end;                    CustomLayoutReporting.ProcessReportData(                        Enum::"Report Selection Usage"::"C.Statement", RecRef, Customer.FieldName("No."),                        Database::Customer, Customer.FieldName("No."), true);                end;            }            action(BackgroundStatement)            {                ApplicationArea = Basic, Suite;                Caption = 'Scheduled Statements';                Image = "Report";                ToolTip = 'Schedule Customer Statements in the Job Queue.';                trigger OnAction()                var                    CustomerLayoutStatement: Codeunit "Customer Layout - Statement";                begin                    CustomerLayoutStatement.EnqueueReport();                end;            }        }        area(Promoted)        {            group(Category_Process)            {                Caption = 'Process', Comment = 'Generated from the PromotedActionCategories property index 1.';                actionref(Contact_Promoted; Contact)                {                }                actionref(ApplyTemplate_Promoted; ApplyTemplate)                {                }                actionref(MergeDuplicate_Promoted; MergeDuplicate)                {                }                actionref(Email_Promoted; Email)                {                }            }            group(Category_Category5)            {                Caption = 'Approve', Comment = 'Generated from the PromotedActionCategories property index 4.';                actionref(Approve_Promoted; Approve)                {                }                actionref(Reject_Promoted; Reject)                {                }                actionref(Comment_Promoted; Comment)                {                }                actionref(Delegate_Promoted; Delegate)                {                }            }            group(Category_Category6)            {                Caption = 'Request Approval', Comment = 'Generated from the PromotedActionCategories property index 5.';                actionref(SendApprovalRequest_Promoted; SendApprovalRequest)                {                }                actionref(CancelApprovalRequest_Promoted; CancelApprovalRequest)                {                }            }            group(Category_Category4)            {                Caption = 'New Document', Comment = 'Generated from the PromotedActionCategories property index 3.';                actionref(NewSalesQuoteAddin_Promoted; NewSalesQuoteAddin)                {                }                actionref(NewSalesQuote_Promoted; NewSalesQuote)                {                }                actionref(NewSalesOrderAddin_Promoted; NewSalesOrderAddin)                {                }                actionref(NewSalesOrder_Promoted; NewSalesOrder)                {                }                actionref(NewSalesInvoiceAddin_Promoted; NewSalesInvoiceAddin)                {                }                actionref(NewSalesInvoice_Promoted; NewSalesInvoice)                {                }                actionref(NewSalesCreditMemoAddin_Promoted; NewSalesCreditMemoAddin)                {                }                actionref(NewSalesCreditMemo_Promoted; NewSalesCreditMemo)                {                }                actionref(NewReminder_Promoted; NewReminder)                {                }            }            group(Category_Category7)            {                Caption = 'Prices & Discounts', Comment = 'Generated from the PromotedActionCategories property index 6.';                actionref(Prices_Promoted; Prices)                {                }                actionref("Line Discounts_Promoted"; "Line Discounts")                {                }                actionref(PriceLists_Promoted; PriceLists)                {                }                actionref("Prices and Discounts Overview_Promoted"; "Prices and Discounts Overview")                {                }                actionref(PriceLines_Promoted; PriceLines)                {                }                actionref(DiscountLines_Promoted; DiscountLines)                {                }            }            group(Category_Category9)            {                Caption = 'Customer', Comment = 'Generated from the PromotedActionCategories property index 8.';                actionref("Ledger E&ntries_Promoted"; "Ledger E&ntries")                {                }                actionref(Dimensions_Promoted; Dimensions)                {                }                actionref(Action76_Promoted; Action76)                {                }                actionref(Attachments_Promoted; Attachments)                {                }                actionref(ApprovalEntries_Promoted; ApprovalEntries)                {                }                actionref("Co&mments_Promoted"; "Co&mments")                {                }                separator(Navigate_Separator)                {                }                actionref(CustomerReportSelections_Promoted; CustomerReportSelections)                {                }                actionref("Bank Accounts_Promoted"; "Bank Accounts")                {                }                actionref(ShipToAddresses_Promoted; ShipToAddresses)                {                }                actionref(AlternativeVATRegistration_Promoted; AlternativeVATRegistration)                {                }                actionref("Direct Debit Mandates_Promoted"; "Direct Debit Mandates")                {                }                actionref("Item References_Promoted"; "Item References")                {                }            }            group(Category_Category8)            {                Caption = 'Navigate', Comment = 'Generated from the PromotedActionCategories property index 7.';            }            group(Category_Report)            {                Caption = 'Report', Comment = 'Generated from the PromotedActionCategories property index 2.';                actionref("Report Statement_Promoted"; "Report Statement")                {                }                actionref("Report Customer - Balance to Date_Promoted"; "Report Customer - Balance to Date")                {                }                actionref("Report Customer Detailed Aging_Promoted"; "Report Customer Detailed Aging")                {                }                actionref(BackgroundStatement_Promoted; BackgroundStatement)                {                }                actionref("S&ales_Promoted"; "S&ales")                {                }            }            group(Category_Synchronize)            {                Caption = 'Synchronize';                Visible = CRMIntegrationEnabled or CDSIntegrationEnabled;                group(Category_Coupling)                {                    Caption = 'Coupling';                    ShowAs = SplitButton;                    actionref(ManageCRMCoupling_Promoted; ManageCRMCoupling)                    {                    }                    actionref(DeleteCRMCoupling_Promoted; DeleteCRMCoupling)                    {                    }                }                actionref(CRMSynchronizeNow_Promoted; CRMSynchronizeNow)                {                }                actionref(CRMGotoAccount_Promoted; CRMGotoAccount)                {                }                actionref(UpdateStatisticsInCRM_Promoted; UpdateStatisticsInCRM)                {                }                actionref(ShowLog_Promoted; ShowLog)                {                }            }        }    }    trigger OnAfterGetCurrRecord()    var        ClientTypeManagement: Codeunit "Client Type Management";    begin        if GuiAllowed() then            OnAfterGetCurrRecordFunc()        else            if ClientTypeManagement.GetCurrentClientType() in [ClientType::ODataV4, ClientType::Api] then                OnAfterGetCurrRecordFuncOData()            else                StartBackgroundCalculations();    end;    local procedure OnAfterGetCurrRecordFunc()    var        WorkflowStepInstance: Record "Workflow Step Instance";        CRMCouplingManagement: Codeunit "CRM Coupling Management";        WorkflowWebhookManagement: Codeunit "Workflow Webhook Management";    begin        if NewMode then            CreateCustomerFromTemplate()        else            StartBackgroundCalculations();        ActivateFields();        SetCreditLimitStyle();        if Rec.GetFilter("Date Filter") = '' then            Rec.SetRange("Date Filter", 0D, WorkDate());        if CRMIntegrationEnabled or CDSIntegrationEnabled then begin            CRMIsCoupledToRecord := CRMCouplingManagement.IsRecordCoupledToCRM(Rec.RecordId);            if Rec."No." <> xRec."No." then                CRMIntegrationManagement.SendResultNotification(Rec);        end;        WorkflowWebhookManagement.GetCanRequestAndCanCancel(Rec.RecordId, CanRequestApprovalForFlow, CanCancelApprovalForFlow);        OpenApprovalEntriesExistCurrUser := false;        if AnyWorkflowExists then begin            CanCancelApprovalForRecord := ApprovalsMgmt.CanCancelApprovalForRecord(Rec.RecordId);            WorkflowStepInstance.SetRange("Record ID", Rec.RecordId);            ShowWorkflowStatus := not WorkflowStepInstance.IsEmpty();            if ShowWorkflowStatus then                CurrPage.WorkflowStatus.PAGE.SetFilterOnWorkflowRecord(Rec.RecordId);            OpenApprovalEntriesExist := ApprovalsMgmt.HasOpenApprovalEntries(Rec.RecordId);            if OpenApprovalEntriesExist then                OpenApprovalEntriesExistCurrUser := ApprovalsMgmt.HasOpenApprovalEntriesForCurrentUser(Rec.RecordId);        end;    end;    trigger OnInit()    var        ApplicationAreaMgmtFacade: Codeunit "Application Area Mgmt. Facade";    begin        PrevCountryCode := '*';        FoundationOnly := ApplicationAreaMgmtFacade.IsFoundationEnabled();        ContactEditable := true;        OpenApprovalEntriesExistCurrUser := true;        CaptionTxt := CurrPage.Caption;        SetCaption(CaptionTxt);        CurrPage.Caption(CaptionTxt);        IsPowerAutomatePrivacyNoticeApproved := PrivacyNotice.GetPrivacyNoticeApprovalState(FlowServiceManagement.GetPowerAutomatePrivacyNoticeId()) = "Privacy Notice Approval State"::Agreed;    end;    trigger OnNewRecord(BelowxRec: Boolean)    var        DocumentNoVisibility: Codeunit DocumentNoVisibility;    begin        if GuiAllowed then            if Rec."No." = '' then                if DocumentNoVisibility.CustomerNoSeriesIsDefault() then                    NewMode := true;    end;    trigger OnOpenPage()    begin        OnBeforeOnOpenPage(Rec);        if Rec.GetFilter("Date Filter") = '' then            Rec.SetRange("Date Filter", 0D, WorkDate());        if GuiAllowed() then            OnOpenPageFunc()        else            OnOpenBackground();        OnAfterOnOpenPage(Rec, xRec);    end;    local procedure OnOpenPageFunc()    var        IntegrationTableMapping: Record "Integration Table Mapping";        EnvironmentInfo: Codeunit "Environment Information";        PriceCalculationMgt: Codeunit "Price Calculation Mgt.";        WorkflowEventHandling: Codeunit "Workflow Event Handling";        OfficeManagement: Codeunit "Office Management";        DocumentNoVisibility: Codeunit DocumentNoVisibility;    begin        CRMIntegrationEnabled := CRMIntegrationManagement.IsCRMIntegrationEnabled();        CDSIntegrationEnabled := CRMIntegrationManagement.IsCDSIntegrationEnabled();        if CRMIntegrationEnabled or CDSIntegrationEnabled then            if IntegrationTableMapping.Get('CUSTOMER') then                BlockedFilterApplied := IntegrationTableMapping.GetTableFilter().Contains('Field39=1(0)');        ExtendedPriceEnabled := PriceCalculationMgt.IsExtendedPriceCalculationEnabled();        OnBeforeGetSalesPricesAndSalesLineDisc(LoadOnDemand);        NoFieldVisible := DocumentNoVisibility.CustomerNoIsVisible();        SalesReceivablesSetup.GetRecordOnce();        IsAllowMultiplePostingGroupsVisible := SalesReceivablesSetup."Allow Multiple Posting Groups";        IsSaaS := EnvironmentInfo.IsSaaS();        IsOfficeAddin := OfficeManagement.IsAvailable();        WorkFlowEventFilter :=            WorkflowEventHandling.RunWorkflowOnSendCustomerForApprovalCode() + '|' +            WorkflowEventHandling.RunWorkflowOnCustomerChangedCode();        SetWorkFlowEnabled();    end;    local procedure OnOpenBackground()    begin        Rec.SetAutoCalcFields("Sales (LCY)", "Profit (LCY)", "Inv. Discounts (LCY)", "Payments (LCY)");    end;    local procedure StartBackgroundCalculations()    var        CustomerCardCalculations: Codeunit "Customer Card Calculations";        Args: Dictionary of [Text, Text];        IsHandled: Boolean;    begin        OnBeforeStartBackgroundCalculations(Rec, IsHandled);        if IsHandled then            exit;        if Rec."No." = PrevCustNo then            exit;        PrevCustNo := Rec."No.";        if (BackgroundTaskId <> 0) then            CurrPage.CancelBackgroundTask(BackgroundTaskId);        DaysPastDueDate := 0;        ExpectedMoneyOwed := 0;        AvgDaysToPay := 0;        TotalMoneyOwed := 0;        AttentionToPaidDay := false;        AmountOnPostedInvoices := 0;        AmountOnPostedCrMemos := 0;        AmountOnOutstandingInvoices := 0;        AmountOnOutstandingCrMemos := 0;        Totals := 0;        AdjmtCostLCY := 0;        AdjCustProfit := 0;        AdjProfitPct := 0;        CustInvDiscAmountLCY := 0;        CustPaymentsLCY := 0;        CustSalesLCY := 0;        CustProfit := 0;        NoPostedInvoices := 0;        NoPostedCrMemos := 0;        NoOutstandingInvoices := 0;        NoOutstandingCrMemos := 0;        OverdueBalance := 0;        LinkedVendorNo := '';        BalanceAsVendor := 0;        BalanceAsVendorEnabled := false;        PaidLateCount := 0;        PaidOnTimeCount := 0;        PercentPaidLate := 0;        OverdueCount := 0;        LastPaymentDate := 0D;        LastPaymentAmount := 0;        InteractionCount := 0;        LastInteractionDate := 0D;        LastInteractionType := '';        MostFrequentInteractionType := '';        DaysSinceLastSale := 0;        DistinctItemsSold := 0;        LastPaymentOnTime := true;        Args.Add(CustomerCardCalculations.GetCustomerNoLabel(), Rec."No.");        Args.Add(CustomerCardCalculations.GetFiltersLabel(), Rec.GetView());        Args.Add(CustomerCardCalculations.GetWorkDateLabel(), Format(WorkDate()));        CurrPage.EnqueueBackgroundTask(BackgroundTaskId, Codeunit::"Customer Card Calculations", Args);        Session.LogMessage('0000D4Q', StrSubstNo(PageBckGrndTaskStartedTxt, Rec.SystemId), Verbosity::Normal, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, 'Category', CustomerCardServiceCategoryTxt);    end;    trigger OnPageBackgroundTaskCompleted(TaskId: Integer; Results: Dictionary of [Text, Text])    var        CustomerCardCalculations: Codeunit "Customer Card Calculations";        DictionaryValue: Text;    begin        if (TaskId = BackgroundTaskId) then begin            if Results.Count() = 0 then                exit;            if TryGetDictionaryValueFromKey(Results, CustomerCardCalculations.GetAvgDaysPastDueDateLabel(), DictionaryValue) then                Evaluate(DaysPastDueDate, DictionaryValue);            if TryGetDictionaryValueFromKey(Results, CustomerCardCalculations.GetExpectedMoneyOwedLabel(), DictionaryValue) then                Evaluate(ExpectedMoneyOwed, DictionaryValue);            if TryGetDictionaryValueFromKey(Results, CustomerCardCalculations.GetAvgDaysToPayLabel(), DictionaryValue) then                Evaluate(AvgDaysToPay, DictionaryValue);            if TryGetDictionaryValueFromKey(Results, CustomerCardCalculations.GetPaidLateCountLabel(), DictionaryValue) then                Evaluate(PaidLateCount, DictionaryValue);            if TryGetDictionaryValueFromKey(Results, CustomerCardCalculations.GetPaidOnTimeCountLabel(), DictionaryValue) then                Evaluate(PaidOnTimeCount, DictionaryValue);            if TryGetDictionaryValueFromKey(Results, CustomerCardCalculations.GetPercentPaidLateLabel(), DictionaryValue) then                Evaluate(PercentPaidLate, DictionaryValue);            if TryGetDictionaryValueFromKey(Results, CustomerCardCalculations.GetOverdueCountLabel(), DictionaryValue) then                Evaluate(OverdueCount, DictionaryValue);            if TryGetDictionaryValueFromKey(Results, CustomerCardCalculations.GetLastPaymentDateLabel(), DictionaryValue) then                Evaluate(LastPaymentDate, DictionaryValue);            if TryGetDictionaryValueFromKey(Results, CustomerCardCalculations.GetLastPaymentAmountLabel(), DictionaryValue) then                Evaluate(LastPaymentAmount, DictionaryValue);            if TryGetDictionaryValueFromKey(Results, CustomerCardCalculations.GetLastPaymentOnTimeLabel(), DictionaryValue) then                Evaluate(LastPaymentOnTime, DictionaryValue);            if TryGetDictionaryValueFromKey(Results, CustomerCardCalculations.GetDaysSinceLastSaleLabel(), DictionaryValue) then                Evaluate(DaysSinceLastSale, DictionaryValue);            if TryGetDictionaryValueFromKey(Results, CustomerCardCalculations.GetDistinctItemsSoldLabel(), DictionaryValue) then                Evaluate(DistinctItemsSold, DictionaryValue);            if TryGetDictionaryValueFromKey(Results, CustomerCardCalculations.GetInteractionCountLabel(), DictionaryValue) then                Evaluate(InteractionCount, DictionaryValue);            if TryGetDictionaryValueFromKey(Results, CustomerCardCalculations.GetLastInteractionDateLabel(), DictionaryValue) then                Evaluate(LastInteractionDate, DictionaryValue);            if TryGetDictionaryValueFromKey(Results, CustomerCardCalculations.GetLastInteractionTypeLabel(), DictionaryValue) then                Evaluate(LastInteractionType, DictionaryValue);            if TryGetDictionaryValueFromKey(Results, CustomerCardCalculations.GetMostFrequentInteractionTypeLabel(), DictionaryValue) then                Evaluate(MostFrequentInteractionType, DictionaryValue);            if TryGetDictionaryValueFromKey(Results, CustomerCardCalculations.GetAmountOnPostedInvoicesLabel(), DictionaryValue) then                Evaluate(AmountOnPostedInvoices, DictionaryValue);            if TryGetDictionaryValueFromKey(Results, CustomerCardCalculations.GetAmountOnPostedCrMemosLabel(), DictionaryValue) then                Evaluate(AmountOnPostedCrMemos, DictionaryValue);            if TryGetDictionaryValueFromKey(Results, CustomerCardCalculations.GetAmountOnOutstandingInvoicesLabel(), DictionaryValue) then                Evaluate(AmountOnOutstandingInvoices, DictionaryValue);            if TryGetDictionaryValueFromKey(Results, CustomerCardCalculations.GetAmountOnOutstandingCrMemosLabel(), DictionaryValue) then                Evaluate(AmountOnOutstandingCrMemos, DictionaryValue);            if TryGetDictionaryValueFromKey(Results, CustomerCardCalculations.GetTotalsLabel(), DictionaryValue) then                Evaluate(Totals, DictionaryValue);            if TryGetDictionaryValueFromKey(Results, CustomerCardCalculations.GetAdjmtCostLCYLabel(), DictionaryValue) then                Evaluate(AdjmtCostLCY, DictionaryValue);            if TryGetDictionaryValueFromKey(Results, CustomerCardCalculations.GetAdjCustProfitLabel(), DictionaryValue) then                Evaluate(AdjCustProfit, DictionaryValue);            if TryGetDictionaryValueFromKey(Results, CustomerCardCalculations.GetAdjProfitPctLabel(), DictionaryValue) then                Evaluate(AdjProfitPct, DictionaryValue);            if TryGetDictionaryValueFromKey(Results, CustomerCardCalculations.GetCustInvDiscAmountLCYLabel(), DictionaryValue) then                Evaluate(CustInvDiscAmountLCY, DictionaryValue);            if TryGetDictionaryValueFromKey(Results, CustomerCardCalculations.GetCustPaymentsLCYLabel(), DictionaryValue) then                Evaluate(CustPaymentsLCY, DictionaryValue);            if TryGetDictionaryValueFromKey(Results, CustomerCardCalculations.GetCustSalesLCYLabel(), DictionaryValue) then                Evaluate(CustSalesLCY, DictionaryValue);            if TryGetDictionaryValueFromKey(Results, CustomerCardCalculations.GetCustProfitLabel(), DictionaryValue) then                Evaluate(CustProfit, DictionaryValue);            if TryGetDictionaryValueFromKey(Results, CustomerCardCalculations.GetNoPostedInvoicesLabel(), DictionaryValue) then                Evaluate(NoPostedInvoices, DictionaryValue);            if TryGetDictionaryValueFromKey(Results, CustomerCardCalculations.GetNoPostedCrMemosLabel(), DictionaryValue) then                Evaluate(NoPostedCrMemos, DictionaryValue);            if TryGetDictionaryValueFromKey(Results, CustomerCardCalculations.GetNoOutstandingInvoicesLabel(), DictionaryValue) then                Evaluate(NoOutstandingInvoices, DictionaryValue);            if TryGetDictionaryValueFromKey(Results, CustomerCardCalculations.GetNoOutstandingCrMemosLabel(), DictionaryValue) then                Evaluate(NoOutstandingCrMemos, DictionaryValue);            if TryGetDictionaryValueFromKey(Results, CustomerCardCalculations.GetOverdueBalanceLabel(), DictionaryValue) then                Evaluate(OverdueBalance, DictionaryValue);            if TryGetDictionaryValueFromKey(Results, CustomerCardCalculations.GetLinkedVendorNoLabel(), DictionaryValue) then                LinkedVendorNo := CopyStr(DictionaryValue, 1, MaxStrLen(LinkedVendorNo));            BalanceAsVendorEnabled := LinkedVendorNo <> '';            if BalanceAsVendorEnabled then                if TryGetDictionaryValueFromKey(Results, CustomerCardCalculations.GetBalanceAsVendorLabel(), DictionaryValue) then                    Evaluate(BalanceAsVendor, DictionaryValue);            AttentionToPaidDay := DaysPastDueDate > 0;            TotalMoneyOwed := Rec."Balance (LCY)" + ExpectedMoneyOwed;            Session.LogMessage('0000D4R', PageBckGrndTaskCompletedTxt, Verbosity::Normal, DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, 'Category', CustomerCardServiceCategoryTxt);        end;    end;    var        SalesReceivablesSetup: Record "Sales & Receivables Setup";        CalendarMgmt: Codeunit "Calendar Management";        ApprovalsMgmt: Codeunit "Approvals Mgmt.";        CRMIntegrationManagement: Codeunit "CRM Integration Management";        CustomerMgt: Codeunit "Customer Mgt.";        FormatAddress: Codeunit "Format Address";        PrivacyNotice: Codeunit "Privacy Notice";        FlowServiceManagement: Codeunit "Flow Service Management";        LinkedVendorNo: Code[20];        BalanceAsVendor: Decimal;        StyleTxt: Text;        CRMIntegrationEnabled: Boolean;        CDSIntegrationEnabled: Boolean;        BlockedFilterApplied: Boolean;        ExtendedPriceEnabled: Boolean;        CRMIsCoupledToRecord: Boolean;        OpenApprovalEntriesExistCurrUser: Boolean;        IsPowerAutomatePrivacyNoticeApproved: Boolean;        OpenApprovalEntriesExist: Boolean;        ShowWorkflowStatus: Boolean;        NoFieldVisible: Boolean;        BalanceExhausted: Boolean;        Totals: Decimal;        AmountOnPostedInvoices: Decimal;        AmountOnPostedCrMemos: Decimal;        AmountOnOutstandingInvoices: Decimal;        AmountOnOutstandingCrMemos: Decimal;        AdjmtCostLCY: Decimal;        AdjCustProfit: Decimal;        CustProfit: Decimal;        AdjProfitPct: Decimal;        CustInvDiscAmountLCY: Decimal;        CustPaymentsLCY: Decimal;        CustSalesLCY: Decimal;        OverdueBalance: Decimal;        OverduePaymentsMsg: Label 'Overdue Payments';        PaidLateCount: Integer;        PaidOnTimeCount: Integer;        PercentPaidLate: Decimal;        OverdueCount: Integer;        LastPaymentDate: Date;        LastPaymentAmount: Decimal;        LastPaymentOnTime: Boolean;        InteractionCount: Integer;        LastInteractionDate: Date;        LastInteractionType: Text[100];        MostFrequentInteractionType: Text[100];        DaysSinceLastSale: Integer;        DistinctItemsSold: Integer;#pragma warning disable AA0470        PostedInvoicesMsg: Label 'Posted Invoices (%1)', Comment = 'Invoices (5)';        CreditMemosMsg: Label 'Posted Credit Memos (%1)', Comment = 'Credit Memos (3)';        OutstandingInvoicesMsg: Label 'Ongoing Invoices (%1)', Comment = 'Ongoing Invoices (4)';        OutstandingCrMemosMsg: Label 'Ongoing Credit Memos (%1)', Comment = 'Ongoing Credit Memos (4)';#pragma warning restore AA0470        ShowMapLbl: Label 'Show on Map';        CustomerCardServiceCategoryTxt: Label 'Customer Card', Locked = true;        PageBckGrndTaskStartedTxt: Label 'Page Background Task to calculate customer statistics for customer %1 started.', Locked = true, Comment = '%1 = Customer No.';        PageBckGrndTaskCompletedTxt: Label 'Page Background Task to calculate customer statistics completed successfully.', Locked = true;        ExpectedMoneyOwed: Decimal;        TotalMoneyOwed: Decimal;        AvgDaysToPay: Decimal;        FoundationOnly: Boolean;        CanCancelApprovalForRecord: Boolean;        EnabledApprovalWorkflowsExist: Boolean;        AnyWorkflowExists: Boolean;        NewMode: Boolean;        WorkFlowEventFilter: Text;        CaptionTxt: Text;        CanRequestApprovalForFlow: Boolean;        CanCancelApprovalForFlow: Boolean;        IsSaaS: Boolean;        IsCountyVisible: Boolean;        IsAllowMultiplePostingGroupsVisible: Boolean;        StatementFileNameTxt: Label 'Statement', Comment = 'Shortened form of ''Customer Statement''';        LoadOnDemand: Boolean;        PrevCustNo: Code[20];        PrevCountryCode: Code[10];        BackgroundTaskId: Integer;        BalanceAsVendorEnabled: Boolean;        PaymentsThisYearTxt: Label 'Payments This Year as of %1', Comment = '%1 = Current Fiscal Year Filter';    protected var        ContactEditable: Boolean;        IsOfficeAddin: Boolean;        NoPostedInvoices: Integer;        NoPostedCrMemos: Integer;        NoOutstandingInvoices: Integer;        NoOutstandingCrMemos: Integer;        AttentionToPaidDay: Boolean;        DaysPastDueDate: Decimal;    [TryFunction]    local procedure TryGetDictionaryValueFromKey(var DictionaryToLookIn: Dictionary of [Text, Text]; KeyToSearchFor: Text; var ReturnValue: Text)    begin        ReturnValue := DictionaryToLookIn.Get(KeyToSearchFor);    end;    local procedure SetWorkFlowEnabled()    var        WorkflowManagement: Codeunit "Workflow Management";    begin        AnyWorkflowExists := WorkflowManagement.AnyWorkflowExists();        EnabledApprovalWorkflowsExist := WorkflowManagement.EnabledWorkflowExist(DATABASE::Customer, WorkFlowEventFilter);    end;    protected procedure ActivateFields()    begin        ContactEditable := Rec."Primary Contact No." = '';        if Rec."Country/Region Code" <> PrevCountryCode then            IsCountyVisible := FormatAddress.UseCounty(Rec."Country/Region Code");        PrevCountryCode := Rec."Country/Region Code";        OnAfterActivateFields(Rec);    end;    local procedure SetCreditLimitStyle()    begin        StyleTxt := '';        BalanceExhausted := false;        if Rec."Credit Limit (LCY)" > 0 then            BalanceExhausted := Rec."Balance (LCY)" >= Rec."Credit Limit (LCY)";        if BalanceExhausted then            StyleTxt := 'Unfavorable';    end;    local procedure HasCustomBaseCalendar(): Boolean    begin        if Rec."Base Calendar Code" = '' then            exit(false)        else            exit(CalendarMgmt.CustomizedChangesExist(Rec));    end;    /// <summary>    /// Runs the specified report filtered to a single customer.    /// </summary>    /// <param name="ReportNumber">The ID of the report to run.</param>    /// <param name="CustomerNumber">The customer number to filter the report.</param>    procedure RunReport(ReportNumber: Integer; CustomerNumber: Code[20])    var        Customer: Record Customer;    begin        Customer.SetRange("No.", CustomerNumber);        REPORT.RunModal(ReportNumber, true, true, Customer);    end;    local procedure CreateCustomerFromTemplate()    var        Customer: Record Customer;        CustomerTemplMgt: Codeunit "Customer Templ. Mgt.";    begin        OnBeforeCreateCustomerFromTemplate(NewMode, Customer);        if not NewMode then            exit;        NewMode := false;        if CustomerTemplMgt.InsertCustomerFromTemplate(Customer) then begin            VerifyVatRegNo(Customer);            Rec.Copy(Customer);            OnCreateCustomerFromTemplateOnBeforeCurrPageUpdate(Rec);            CurrPage.Update();        end else            if CustomerTemplMgt.TemplatesAreNotEmpty() then                if not CustomerTemplMgt.IsOpenBlankCardConfirmed() then                    CurrPage.Close();    end;    local procedure VerifyVatRegNo(var Customer: Record Customer)    var        VATRegNoSrvConfig: Record "VAT Reg. No. Srv Config";        EUVATRegistrationNoCheck: Page "EU VAT Registration No Check";        CustomerRecRef: RecordRef;    begin        if VATRegNoSrvConfig.VATRegNoSrvIsEnabled() then            if Customer."Validate EU Vat Reg. No." then begin                EUVATRegistrationNoCheck.SetRecordRef(Customer);                Commit();                EUVATRegistrationNoCheck.RunModal();                EUVATRegistrationNoCheck.GetRecordRef(CustomerRecRef);                CustomerRecRef.SetTable(Customer);            end;    end;    local procedure OpenCurrFiscalYearCustLedgerEntries()    var        CustLedgerEntries: Record "Cust. Ledger Entry";    begin        CustLedgerEntries.SetCurrentKey("Customer No.", "Posting Date", "Currency Code");        CustLedgerEntries.SetRange("Customer No.", Rec."No.");        CustLedgerEntries.SetFilter("Posting Date", CustomerMgt.GetCurrentYearFilter());        Page.Run(0, CustLedgerEntries);    end;    local procedure OpenCurrFiscalYearDetailedCustLedgerEntries()    var        DetailedCustLedgEntry: Record "Detailed Cust. Ledg. Entry";    begin        DetailedCustLedgEntry.SetCurrentKey("Customer No.", "Posting Date", "Currency Code");        DetailedCustLedgEntry.SetRange("Customer No.", Rec."No.");        DetailedCustLedgEntry.SetRange("Initial Document Type", DetailedCustLedgEntry."Initial Document Type"::Payment);        DetailedCustLedgEntry.SetRange("Entry Type", DetailedCustLedgEntry."Entry Type"::"Initial Entry");        DetailedCustLedgEntry.SetFilter("Posting Date", CustomerMgt.GetCurrentYearFilter());        Page.Run(0, DetailedCustLedgEntry);    end;    local procedure OnAfterGetCurrRecordFuncOData()    begin        CustomerMgt.CalculateStatistic(Rec, AdjmtCostLCY, AdjCustProfit, AdjProfitPct, CustInvDiscAmountLCY, CustPaymentsLCY, CustSalesLCY, CustProfit);    end;    /// <summary>    /// Raised after activating the fields on the customer card.    /// </summary>    /// <param name="Customer">The customer record.</param>    [IntegrationEvent(true, false)]    local procedure OnAfterActivateFields(var Customer: Record Customer)    begin    end;    /// <summary>    /// Raised after opening the customer card page.    /// </summary>    /// <param name="Customer">The current customer record.</param>    /// <param name="xCustomer">The previous customer record.</param>    [IntegrationEvent(true, false)]    local procedure OnAfterOnOpenPage(var Customer: Record Customer; xCustomer: Record Customer)    begin    end;    /// <summary>    /// Raised to allow customization of the page caption.    /// </summary>    /// <param name="InText">The caption text to modify.</param>    [IntegrationEvent(false, false)]    [Scope('OnPrem')]    procedure SetCaption(var InText: Text)    begin    end;    /// <summary>    /// Raised before creating a customer from a template.    /// </summary>    /// <param name="NewMode">Indicates whether the page is in new mode.</param>    /// <param name="Customer">The customer record to be created.</param>    [IntegrationEvent(false, false)]    local procedure OnBeforeCreateCustomerFromTemplate(var NewMode: Boolean; var Customer: Record Customer)    begin    end;    /// <summary>    /// Raised before loading sales prices and line discounts.    /// </summary>    /// <param name="LoadOnDemand">Set to control whether prices load on demand.</param>    [IntegrationEvent(false, false)]    local procedure OnBeforeGetSalesPricesAndSalesLineDisc(var LoadOnDemand: Boolean)    begin    end;    /// <summary>    /// Raised before updating the current page after creating a customer from template.    /// </summary>    /// <param name="Customer">The newly created customer record.</param>    [IntegrationEvent(false, false)]    local procedure OnCreateCustomerFromTemplateOnBeforeCurrPageUpdate(var Customer: Record Customer)    begin    end;    /// <summary>    /// Raised before opening the customer card page.    /// </summary>    /// <param name="Customer">The customer record.</param>    [IntegrationEvent(true, false)]    local procedure OnBeforeOnOpenPage(var Customer: Record Customer)    begin    end;    /// <summary>    /// Raised before starting background calculations on the customer card.    /// </summary>    /// <param name="Customer">The customer record.</param>    /// <param name="IsHandled">Set to true to skip background calculations.</param>    [IntegrationEvent(true, false)]    local procedure OnBeforeStartBackgroundCalculations(var Customer: Record Customer; var IsHandled: Boolean)    begin    end;}