microsoft / ALAppExtensions

Repository for collaboration on Microsoft AL application add-on and localization extensions for Microsoft Dynamics 365 Business Central.
MIT License
785 stars 620 forks source link

page 26 "Vendor Card" - OnBeforeActivateFields - Event Request #13911

Closed ZacRyon closed 3 years ago

ZacRyon commented 3 years ago

page 26 "Vendor Card" { Caption = 'Vendor Card'; PageType = Card; PromotedActionCategories = 'New,Process,Report,Approve,Request Approval,New Document,Navigate,Incoming Documents,Vendor'; RefreshOnActivate = true; SourceTable = Vendor;

layout
{
    area(content)
    {
        group(General)
        {
            Caption = 'General';
            field("No."; "No.")
            {
                ApplicationArea = All;
                Importance = Standard;
                ToolTip = 'Specifies the number of the involved entry or record, according to the specified number series.';
                Visible = NoFieldVisible;

                trigger OnAssistEdit()
                begin
                    if AssistEdit(xRec) then
                        CurrPage.Update();
                end;
            }
            field(Name; Name)
            {
                ApplicationArea = All;
                Importance = Promoted;
                ShowMandatory = true;
                ToolTip = 'Specifies the vendor''s name. You can enter a maximum of 30 characters, both numbers and letters.';

                trigger OnValidate()
                begin
                    CurrPage.Update(true);
                end;
            }
            field("Name 2"; "Name 2")
            {
                ApplicationArea = All;
                Importance = Additional;
                ToolTip = 'Specifies an additional part of the name.';
                Visible = false;
            }
            field(Blocked; Blocked)
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies which transactions with the vendor that cannot be processed, for example a vendor that is declared insolvent.';
            }
            field("Privacy Blocked"; "Privacy Blocked")
            {
                ApplicationArea = Basic, Suite;
                Importance = Additional;
                ToolTip = 'Specifies whether to limit access to data for the data subject during daily operations. This is useful, for example, when protecting data from changes while it is under privacy review.';
            }
            field("Last Date Modified"; "Last Date Modified")
            {
                ApplicationArea = Basic, Suite;
                Importance = Additional;
                ToolTip = 'Specifies when the vendor card was last modified.';
            }
            field("Balance (LCY)"; "Balance (LCY)")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the total value of your completed purchases from the vendor in the current fiscal year. It is calculated from amounts excluding VAT on all completed purchase invoices and credit memos.';

                trigger OnDrillDown()
                begin
                    OpenVendorLedgerEntries(false);
                end;
            }
            field("Balance Due (LCY)"; "Balance Due (LCY)")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the total value of your unpaid purchases from the vendor in the current fiscal year. It is calculated from amounts excluding VAT on all open purchase invoices and credit memos.';

                trigger OnDrillDown()
                begin
                    OpenVendorLedgerEntries(true);
                end;
            }
            field("Document Sending Profile"; "Document Sending Profile")
            {
                ApplicationArea = Basic, Suite;
                Importance = Additional;
                ToolTip = 'Specifies the preferred method of sending documents to this vendor, so that you do not have to select a sending option every time that you post and send a document to the vendor. Documents to this vendor will be sent using the specified sending profile and will override the default document sending profile.';
            }
            field("Search Name"; "Search Name")
            {
                ApplicationArea = Basic, Suite;
                Importance = Additional;
                ToolTip = 'Specifies an alternate name that you can use to search for the record in question when you cannot remember the value in the Name field.';
            }
            field("IC Partner Code"; "IC Partner Code")
            {
                ApplicationArea = Intercompany;
                Importance = Additional;
                ToolTip = 'Specifies the vendor''s IC partner code, if the vendor is one of your intercompany partners.';
            }
            field("Purchaser Code"; "Purchaser Code")
            {
                ApplicationArea = Suite;
                Importance = Additional;
                ToolTip = 'Specifies which purchaser is assigned to the vendor.';
            }
            field("Responsibility Center"; "Responsibility Center")
            {
                ApplicationArea = Suite;
                Importance = Additional;
                ToolTip = 'Specifies the code of the responsibility center, such as a distribution hub, that is associated with the involved user, company, customer, or vendor.';
            }
            field("Disable Search by Name"; "Disable Search by Name")
            {
                ApplicationArea = Basic, Suite;
                Importance = Additional;
                ToolTip = 'Specifies that you can change vendor name in the document, because the name is not used in search.';
            }
        }
        group("Address & Contact")
        {
            Caption = 'Address & Contact';
            group(AddressDetails)
            {
                Caption = 'Address';
                field(Address; Address)
                {
                    ApplicationArea = Basic, Suite;
                    ToolTip = 'Specifies the vendor''s address.';
                }
                field("Address 2"; "Address 2")
                {
                    ApplicationArea = Basic, Suite;
                    ToolTip = 'Specifies additional address information.';
                }
                field("Country/Region Code"; "Country/Region Code")
                {
                    ApplicationArea = Basic, Suite;
                    ToolTip = 'Specifies the country/region of the address.';

                    trigger OnValidate()
                    begin
                        IsCountyVisible := FormatAddress.UseCounty("Country/Region Code");
                    end;
                }
                field(City; City)
                {
                    ApplicationArea = Basic, Suite;
                    ToolTip = 'Specifies the vendor''s city.';
                }
                group(Control199)
                {
                    ShowCaption = false;
                    Visible = IsCountyVisible;
                    field(County; County)
                    {
                        ApplicationArea = Basic, Suite;
                        ToolTip = 'Specifies the state, province or county as a part of the address.';
                    }
                }
                field("Post Code"; "Post Code")
                {
                    ApplicationArea = Basic, Suite;
                    Importance = Promoted;
                    ToolTip = 'Specifies the postal code.';
                }
                field(ShowMap; ShowMapLbl)
                {
                    ApplicationArea = Basic, Suite;
                    Editable = false;
                    ShowCaption = false;
                    Style = StrongAccent;
                    StyleExpr = TRUE;
                    ToolTip = 'Specifies you can view the vendor''s address on your preferred map website.';

                    trigger OnDrillDown()
                    begin
                        CurrPage.Update(true);
                        DisplayMap;
                    end;
                }
            }
            field("Phone No."; "Phone No.")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the vendor''s telephone number.';
            }
            field(MobilePhoneNo; "Mobile Phone No.")
            {
                Caption = 'Mobile Phone No.';
                ApplicationArea = Basic, Suite;
                ExtendedDatatype = PhoneNo;
                ToolTip = 'Specifies the vendor''s mobile telephone number.';
            }
            field("E-Mail"; "E-Mail")
            {
                ApplicationArea = Basic, Suite;
                ExtendedDatatype = EMail;
                Importance = Promoted;
                ToolTip = 'Specifies the vendor''s email address.';
            }
            field("Fax No."; "Fax No.")
            {
                ApplicationArea = Basic, Suite;
                Importance = Additional;
                ToolTip = 'Specifies the vendor''s fax number.';
            }
            field("Home Page"; "Home Page")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the vendor''s web site.';
            }
            field("Our Account No."; "Our Account No.")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies your account number with the vendor, if you have one.';
            }
            field("Language Code"; "Language Code")
            {
                ApplicationArea = Basic, Suite;
                Importance = Additional;
                ToolTip = 'Specifies the language that is used when translating specified text on documents to foreign business partner, such as an item description on an order confirmation.';
            }
            group(Contact)
            {
                Caption = 'Contact';
                field("Primary Contact No."; "Primary Contact No.")
                {
                    ApplicationArea = Basic, Suite;
                    Caption = 'Primary Contact Code';
                    ToolTip = 'Specifies the primary contact number for the vendor.';
                }
                field(Control16; Contact)
                {
                    ApplicationArea = Basic, Suite;
                    Editable = ContactEditable;
                    Importance = Promoted;
                    ToolTip = 'Specifies the name of the person you regularly contact when you do business with this vendor.';

                    trigger OnValidate()
                    begin
                        ContactOnAfterValidate;
                    end;
                }
            }
        }
        group(Invoicing)
        {
            Caption = 'Invoicing';
            field("VAT Registration No."; "VAT Registration No.")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the vendor''s VAT registration number.';
            }
            field("EORI Number"; "EORI Number")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the Economic Operators Registration and Identification number that is used when you exchange information with the customs authorities due to trade into or out of the European Union.';
                Visible = false;
            }
            field(GLN; GLN)
            {
                ApplicationArea = Basic, Suite;
                Importance = Additional;
                ToolTip = 'Specifies the vendor in connection with electronic document receiving.';
            }
            field("Tax Liable"; "Tax Liable")
            {
                ApplicationArea = SalesTax;
                ToolTip = 'Specifies if the customer is liable for sales tax.';
            }
            field("Tax Area Code"; "Tax Area Code")
            {
                ApplicationArea = SalesTax;
                ShowMandatory = true;
                ToolTip = 'Specifies a tax area code for the company.';
            }
            field("Pay-to Vendor No."; "Pay-to Vendor No.")
            {
                ApplicationArea = Basic, Suite;
                Importance = Additional;
                ToolTip = 'Specifies the number of a different vendor whom you pay for products delivered by the vendor on the vendor card.';
            }
            field("Bank Communication"; "Bank Communication")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the language of the check image.';
            }
            field("Invoice Disc. Code"; "Invoice Disc. Code")
            {
                ApplicationArea = Basic, Suite;
                Importance = Additional;
                NotBlank = true;
                ToolTip = 'Specifies the vendor''s invoice discount code. When you set up a new vendor card, the number you have entered in the No. field is automatically inserted.';
            }
            field("Prices Including VAT"; "Prices Including VAT")
            {
                ApplicationArea = VAT;
                ToolTip = 'Specifies if the Unit Price and Line Amount fields on document lines should be shown with or without VAT.';
            }
            field("Price Calculation Method"; "Price Calculation Method")
            {
                Visible = ExtendedPriceEnabled;
                ApplicationArea = Basic, Suite;
                Importance = Promoted;
                ToolTip = 'Specifies the default price calculation method.';
            }
            group("Posting Details")
            {
                Caption = 'Posting Details';
                field("Gen. Bus. Posting Group"; "Gen. Bus. Posting Group")
                {
                    ApplicationArea = Basic, Suite;
                    Importance = Additional;
                    ShowMandatory = true;
                    ToolTip = 'Specifies the vendor''s trade type to link transactions made for this vendor with the appropriate general ledger account according to the general posting setup.';
                }
                field("VAT Bus. Posting Group"; "VAT Bus. Posting Group")
                {
                    ApplicationArea = Basic, Suite;
                    Importance = Additional;
                    ToolTip = 'Specifies the VAT specification of the involved customer or vendor to link transactions made for this record with the appropriate general ledger account according to the VAT posting setup.';
                    Visible = UseVAT;
                }
                field("Vendor Posting Group"; "Vendor Posting Group")
                {
                    ApplicationArea = Basic, Suite;
                    Importance = Additional;
                    ShowMandatory = true;
                    ToolTip = 'Specifies the vendor''s market type to link business transactions made for the vendor with the appropriate account in the general ledger.';
                }
            }
            group("Foreign Trade")
            {
                Caption = 'Foreign Trade';
                field("Currency Code"; "Currency Code")
                {
                    ApplicationArea = Suite;
                    Importance = Additional;
                    ToolTip = 'Specifies the currency code that is inserted by default when you create purchase documents or journal lines for the vendor.';
                }
            }
        }
        group(Payments)
        {
            Caption = 'Payments';
            field("Prepayment %"; "Prepayment %")
            {
                ApplicationArea = Prepayments;
                Importance = Additional;
                ToolTip = 'Specifies a prepayment percentage that applies to all orders for this vendor, regardless of the items or services on the order lines.';
            }
            field("Application Method"; "Application Method")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies how to apply payments to entries for this vendor.';
            }
            field("Payment Terms Code"; "Payment Terms Code")
            {
                ApplicationArea = Basic, Suite;
                Importance = Promoted;
                ToolTip = 'Specifies a formula that calculates the payment due date, payment discount date, and payment discount amount.';
            }
            field("Payment Method Code"; "Payment Method Code")
            {
                ApplicationArea = Basic, Suite;
                Importance = Promoted;
                ToolTip = 'Specifies how to make payment, such as with bank transfer, cash, or check.';
            }
            field(Priority; Priority)
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the importance of the vendor when suggesting payments using the Suggest Vendor Payments function.';
            }
            field("Block Payment Tolerance"; "Block Payment Tolerance")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies if the vendor allows payment tolerance.';

                trigger OnValidate()
                var
                    ConfirmManagement: Codeunit "Confirm Management";
                begin
                    if "Block Payment Tolerance" then begin
                        if ConfirmManagement.GetResponseOrDefault(Text002, true) then
                            PaymentToleranceMgt.DelTolVendLedgEntry(Rec);
                    end else begin
                        if ConfirmManagement.GetResponseOrDefault(Text001, true) then
                            PaymentToleranceMgt.CalcTolVendLedgEntry(Rec);
                    end;
                end;
            }
            field("Preferred Bank Account Code"; "Preferred Bank Account Code")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the vendor bank account that will be used by default on payment journal lines for export to a payment bank file.';
            }
            field("Partner Type"; "Partner Type")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies if the vendor is a person or a company.';
            }
            field("Cash Flow Payment Terms Code"; "Cash Flow Payment Terms Code")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies a payment term that will be used for calculating cash flow.';
            }
            field("IRS 1099 Code"; "IRS 1099 Code")
            {
                ApplicationArea = BasicUS;
                Importance = Additional;
                ToolTip = 'Specifies a 1099 code for the vendor.';
            }
            field("FATCA filing requirement"; "FATCA filing requirement")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies if the vendor is set up to require FATCA filing.';
            }
            field("Federal ID No."; "Federal ID No.")
            {
                ApplicationArea = Basic, Suite;
                Importance = Promoted;
                ToolTip = 'Specifies the vendor''s Taxpayer Identification Number (TIN). The vendor is assigned this number by the tax authorities.';
            }
            field("Tax Identification Type"; "Tax Identification Type")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the tax identification type for the customer. This information is used for tax reporting. The identification type used for a customer depends on whether the customer is classified as a company or as a person.';
            }
            field("RFC No."; "RFC No.")
            {
                ApplicationArea = BasicMX;
                Importance = Additional;
                ToolTip = 'Specifies the federal registration number for taxpayers.';
            }
            field("CURP No."; "CURP No.")
            {
                ApplicationArea = BasicMX;
                Importance = Additional;
                ToolTip = 'Specifies the unique fiscal card identification number. The CURP number must contain 18 digits.';
            }
            field("State Inscription"; "State Inscription")
            {
                ApplicationArea = BasicMX;
                ToolTip = 'Specifies the tax ID number that is assigned by state tax authorities to every person or corporation.';
            }
            field("Creditor No."; "Creditor No.")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the number of the vendor.';
            }
            field("Check Date Format"; "Check Date Format")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies how the date will appear on the printed check image for this bank account.';
            }
            field("Check Date Separator"; "Check Date Separator")
            {
                ApplicationArea = Basic, Suite;
                ToolTip = 'Specifies the character that separates Month, Day and Year of the date that prints on the check image.';
            }
        }
        group(Receiving)
        {
            Caption = 'Receiving';
            field("Location Code"; "Location Code")
            {
                ApplicationArea = Location;
                Importance = Promoted;
                ToolTip = 'Specifies the warehouse location where items from the vendor must be received by default.';
            }
            field("Shipment Method Code"; "Shipment Method Code")
            {
                ApplicationArea = Suite;
                Importance = Promoted;
                ToolTip = 'Specifies the delivery conditions of the related shipment, such as free on board (FOB).';
            }
            field("Shipping Agent Code"; "Shipping Agent Code")
            {
                ToolTip = 'Specifies the code for the shipping agent who is transporting the items.';
            }
            field("Lead Time Calculation"; "Lead Time Calculation")
            {
                ApplicationArea = Basic, Suite;
                Importance = Promoted;
                ToolTip = 'Specifies a date formula for the amount of time it takes to replenish the item.';
            }
            field("Base Calendar Code"; "Base Calendar Code")
            {
                ApplicationArea = Basic, Suite;
                DrillDown = false;
                ToolTip = 'Specifies a customizable calendar for delivery planning that holds the vendor''s working days and holidays.';
            }
            field("Customized Calendar"; format(CalendarMgmt.CustomizedChangesExist(Rec)))
            {
                ApplicationArea = Basic, Suite;
                Caption = 'Customized Calendar';
                Editable = false;
                ToolTip = 'Specifies if you have set up a customized calendar for the vendor.';

                trigger OnDrillDown()
                begin
                    CurrPage.SaveRecord;
                    TestField("Base Calendar Code");
                    CalendarMgmt.ShowCustomizedCalendar(Rec);
                end;
            }
            field("Over-Receipt Code"; "Over-Receipt Code")
            {
                ApplicationArea = All;
                Visible = OverReceiptAllowed;
                ToolTip = 'Specifies the policy that will be used for the vendor if more items than ordered are received.';
            }
        }
    }
    area(factboxes)
    {
        part(Control82; "Vendor Picture")
        {
            ApplicationArea = Basic, Suite;
            SubPageLink = "No." = FIELD("No.");
            Visible = NOT IsOfficeAddin;
        }
        part("Attached Documents"; "Document Attachment Factbox")
        {
            ApplicationArea = All;
            Caption = 'Attachments';
            SubPageLink = "Table ID" = CONST(23),
                          "No." = FIELD("No.");
        }
        part(VendorStatisticsFactBox; "Vendor Statistics 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");
        }
        part(AgedAccPayableChart; "Aged Acc. Payable Chart")
        {
            ApplicationArea = Basic, Suite;
            SubPageLink = "No." = FIELD("No.");
            Visible = IsOfficeAddin;
        }
        part(Control17; "Social Listening FactBox")
        {
            ApplicationArea = All;
            SubPageLink = "Source Type" = CONST(Vendor),
                          "Source No." = FIELD("No.");
            Visible = false;
            ObsoleteState = Pending;
            ObsoleteReason = 'Microsoft Social Engagement has been discontinued.';
            ObsoleteTag = '17.0';
        }
        part(Control19; "Social Listening Setup FactBox")
        {
            ApplicationArea = All;
            SubPageLink = "Source Type" = CONST(Vendor),
                          "Source No." = FIELD("No.");
            UpdatePropagation = Both;
            Visible = false;
            ObsoleteState = Pending;
            ObsoleteReason = 'Microsoft Social Engagement has been discontinued.';
            ObsoleteTag = '17.0';
        }
        part(VendorHistBuyFromFactBox; "Vendor Hist. Buy-from 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(VendorHistPayToFactBox; "Vendor Hist. Pay-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(WorkflowStatus; "Workflow Status FactBox")
        {
            ApplicationArea = All;
            Editable = false;
            Enabled = false;
            ShowFilter = false;
            Visible = ShowWorkflowStatus;
        }
        systempart(Control1900383207; Links)
        {
            ApplicationArea = RecordLinks;
        }
        systempart(Control1905767507; Notes)
        {
            ApplicationArea = Notes;
            Editable = true;
        }
    }
}

actions
{
    area(navigation)
    {
        group("Ven&dor")
        {
            Caption = 'Ven&dor';
            Image = Vendor;
            action(Dimensions)
            {
                ApplicationArea = Dimensions;
                Caption = 'Dimensions';
                Image = Dimensions;
                Promoted = true;
                PromotedCategory = Category9;
                PromotedIsBig = true;
                RunObject = Page "Default Dimensions";
                RunPageLink = "Table ID" = CONST(23),
                              "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;
                Promoted = true;
                PromotedCategory = Category7;
                RunObject = Page "Vendor Bank Account List";
                RunPageLink = "Vendor No." = FIELD("No.");
                ToolTip = 'View or set up the vendor''s bank accounts. You can set up any number of bank accounts for each vendor.';
            }
            action(ContactBtn)
            {
                AccessByPermission = TableData Contact = R;
                ApplicationArea = Basic, Suite;
                Caption = 'C&ontact';
                Image = ContactPerson;
                Promoted = true;
                PromotedCategory = Category7;
                PromotedIsBig = true;
                ToolTip = 'View or edit detailed information about the contact person at the vendor.';

                trigger OnAction()
                begin
                    ShowContact;
                end;
            }
            action(OrderAddresses)
            {
                ApplicationArea = Basic, Suite;
                Caption = 'Order &Addresses';
                Image = Addresses;
                RunObject = Page "Order Address List";
                RunPageLink = "Vendor No." = FIELD("No.");
                ToolTip = 'View a list of alternate order addresses for the vendor.';
            }
            action("&Locations")
            {
                Caption = '&Locations';
                Image = Warehouse;
                RunObject = Page "Vendor Locations";
                RunPageLink = "Vendor No." = FIELD("No.");
                ToolTip = 'View the location for the vendor.';
            }
            action("Co&mments")
            {
                ApplicationArea = Comments;
                Caption = 'Co&mments';
                Image = ViewComments;
                Promoted = true;
                PromotedCategory = Category9;
                RunObject = Page "Comment Sheet";
                RunPageLink = "Table Name" = CONST(Vendor),
                              "No." = FIELD("No.");
                ToolTip = 'View or add comments for the record.';
            }
            action(ApprovalEntries)
            {
                AccessByPermission = TableData "Approval Entry" = R;
                ApplicationArea = Suite;
                Caption = 'Approvals';
                Image = Approvals;
                Promoted = true;
                PromotedCategory = Category9;
                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(RecordId);
                end;
            }

if not CLEAN18

            action("Cross References")
            {
                ApplicationArea = Basic, Suite;
                Caption = 'Cross References';
                Image = Change;
                ObsoleteState = Pending;
                ObsoleteReason = 'Replaced by Item Reference feature.';
                ObsoleteTag = '18.0';
                Promoted = true;
                PromotedCategory = Category9;
                RunObject = Page "Cross References";
                RunPageLink = "Cross-Reference Type" = CONST(Vendor),
                              "Cross-Reference Type No." = FIELD("No.");
                RunPageView = SORTING("Cross-Reference Type", "Cross-Reference Type No.");
                ToolTip = 'Set up a customer''s or vendor''s own identification of the selected item. Cross-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.';
            }

endif

            action("Item References")
            {
                ApplicationArea = Basic, Suite;
                Caption = 'Item References';
                Image = Change;
                Visible = ItemReferenceVisible;
                Promoted = true;
                PromotedCategory = Category9;
                RunObject = Page "Item References";
                RunPageLink = "Reference Type" = CONST(Vendor),
                              "Reference Type No." = FIELD("No.");
                RunPageView = SORTING("Reference Type", "Reference Type No.");
                ToolTip = 'Set up a customer''s or vendor''s own identification of the selected item. 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(VendorReportSelections)
            {
                ApplicationArea = Basic, Suite;
                Caption = 'Document Layouts';
                Image = Quote;
                Promoted = true;
                PromotedCategory = Category7;
                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::Vendor);
                    CustomReportSelection.SetRange("Source No.", "No.");
                    PAGE.RunModal(PAGE::"Vendor Report Selections", CustomReportSelection);
                end;
            }
            action(SentEmails)
            {
                ApplicationArea = Basic, Suite;
                Caption = 'Sent Emails';
                Image = ShowList;
                Promoted = true;
                PromotedCategory = Category7;
                ToolTip = 'View a list of emails that you have sent to this vendor.';

                trigger OnAction()
                var
                    Email: Codeunit Email;
                begin
                    Email.OpenSentEmails(Database::Vendor, Rec.SystemId);
                end;
            }
            action(Attachments)
            {
                ApplicationArea = All;
                Caption = 'Attachments';
                Image = Attach;
                Promoted = true;
                PromotedCategory = Category9;
                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;
            }
        }
        group("&Purchases")
        {
            Caption = '&Purchases';
            Image = Purchasing;
            action(Items)
            {
                ApplicationArea = Planning;
                Caption = 'Items';
                Image = Item;
                RunObject = Page "Vendor Item Catalog";
                RunPageLink = "Vendor No." = FIELD("No.");
                RunPageView = SORTING("Vendor No.", "Item No.");
                ToolTip = 'Open the list of items that you trade in.';
            }
            action("Invoice &Discounts")
            {
                ApplicationArea = Suite;
                Caption = 'Invoice &Discounts';
                Image = CalculateInvoiceDiscount;
                RunObject = Page "Vend. Invoice Discounts";
                RunPageLink = Code = FIELD("Invoice Disc. Code");
                ToolTip = 'Set up different discounts that are applied to invoices for the vendor. An invoice discount is automatically granted to the vendor when the total on a sales invoice exceeds a certain amount.';
            }
            action(PriceLists)
            {
                ApplicationArea = Basic, Suite;
                Caption = 'Purchase Price Lists';
                Image = Price;
                Promoted = true;
                PromotedCategory = Category7;
                Visible = ExtendedPriceEnabled;
                ToolTip = 'View or set up purchase price lists for products that you buy from the vendor. An product price is automatically granted on invoice lines when the specified criteria are met, such as vendor, quantity, or ending date.';

                trigger OnAction()
                var
                    PriceUXManagement: Codeunit "Price UX Management";
                begin
                    PriceUXManagement.ShowPriceLists(Rec, "Price Amount Type"::Any);
                end;
            }
            action(PriceLines)
            {
                AccessByPermission = TableData "Purchase Price Access" = R;
                ApplicationArea = Basic, Suite;
                Caption = 'Purchase Prices';
                Image = Price;
                Scope = Repeater;
                Promoted = true;
                PromotedCategory = Category7;
                Visible = ExtendedPriceEnabled;
                ToolTip = 'View or set up purchase price lines for products that you buy from the vendor. A product price is automatically granted on invoice lines when the specified criteria are met, such as vendor, quantity, or ending date.';

                trigger OnAction()
                var
                    PriceSource: Record "Price Source";
                    PriceUXManagement: Codeunit "Price UX Management";
                begin
                    Rec.ToPriceSource(PriceSource);
                    PriceUXManagement.ShowPriceListLines(PriceSource, "Price Amount Type"::Price);
                end;
            }
            action(DiscountLines)
            {
                AccessByPermission = TableData "Purchase Discount Access" = R;
                ApplicationArea = Basic, Suite;
                Caption = 'Purchase Discounts';
                Image = LineDiscount;
                Scope = Repeater;
                Promoted = true;
                PromotedCategory = Category7;
                Visible = ExtendedPriceEnabled;
                ToolTip = 'View or set up different discounts for products that you buy from the vendor. A product line discount is automatically granted on invoice lines when the specified criteria are met, such as vendor, quantity, or ending date.';

                trigger OnAction()
                var
                    PriceSource: Record "Price Source";
                    PriceUXManagement: Codeunit "Price UX Management";
                begin
                    Rec.ToPriceSource(PriceSource);
                    PriceUXManagement.ShowPriceListLines(PriceSource, "Price Amount Type"::Discount);
                end;
            }

if not CLEAN18

            action(PriceListsDiscounts)
            {
                ApplicationArea = Basic, Suite;
                Caption = 'Price Lists (Discounts)';
                Image = LineDiscount;
                Visible = false;
                ToolTip = 'View or set up different discounts for products that you buy from the vendor. An product discount is automatically granted on invoice lines when the specified criteria are met, such as vendor, quantity, or ending date.';
                ObsoleteState = Pending;
                ObsoleteReason = 'Action PriceLists shows all purchase price lists with prices and discounts';
                ObsoleteTag = '18.0';

                trigger OnAction()
                var
                    PriceUXManagement: Codeunit "Price UX Management";
                    AmountType: Enum "Price Amount Type";
                begin
                    PriceUXManagement.ShowPriceLists(Rec, AmountType::Discount);
                end;
            }

endif

if not CLEAN17

            action(Prices)
            {
                ApplicationArea = Basic, Suite;
                Caption = 'Prices';
                Image = Price;
                Promoted = true;
                PromotedCategory = Category7;
                Visible = not ExtendedPriceEnabled;
                RunObject = Page "Purchase Prices";
                RunPageLink = "Vendor No." = FIELD("No.");
                RunPageView = SORTING("Vendor No.");
                ToolTip = 'View or set up different prices for items that you buy from the vendor. An item price is automatically granted on invoice lines when the specified criteria are met, such as vendor, quantity, or ending date.';
                ObsoleteState = Pending;
                ObsoleteReason = 'Replaced by the new implementation (V16) of price calculation.';
                ObsoleteTag = '17.0';
            }
            action("Line Discounts")
            {
                ApplicationArea = Basic, Suite;
                Caption = 'Line Discounts';
                Image = LineDiscount;
                Promoted = true;
                PromotedCategory = Category7;
                Visible = not ExtendedPriceEnabled;
                RunObject = Page "Purchase Line Discounts";
                RunPageLink = "Vendor No." = FIELD("No.");
                RunPageView = SORTING("Vendor No.");
                ToolTip = 'View or set up different discounts for items that you buy from the vendor. An item discount is automatically granted on invoice lines when the specified criteria are met, such as vendor, quantity, or ending date.';
                ObsoleteState = Pending;
                ObsoleteReason = 'Replaced by the new implementation (V16) of price calculation.';
                ObsoleteTag = '17.0';
            }

endif

            action("Prepa&yment Percentages")
            {
                ApplicationArea = Prepayments;
                Caption = 'Prepa&yment Percentages';
                Image = PrepaymentPercentages;
                RunObject = Page "Purchase Prepmt. Percentages";
                RunPageLink = "Vendor No." = FIELD("No.");
                RunPageView = SORTING("Vendor No.");
                ToolTip = 'View or edit the percentages of the price that can be paid as a prepayment. ';
            }
            action("Recurring Purchase Lines")
            {
                ApplicationArea = Suite;
                Caption = 'Recurring Purchase Lines';
                Image = CodesList;
                RunObject = Page "Standard Vendor Purchase Codes";
                RunPageLink = "Vendor No." = FIELD("No.");
                ToolTip = 'View or edit recurring purchase lines for the vendor.';
            }
            action("Mapping Text to Account")
            {
                ApplicationArea = Basic, Suite;
                Caption = 'Mapping Text to Account';
                Image = MapAccounts;
                RunObject = Page "Text-to-Account Mapping Wksh.";
                RunPageLink = "Vendor No." = FIELD("No.");
                ToolTip = 'Page mapping text to account';
            }
        }
        group(Documents)
        {
            Caption = 'Documents';
            Image = Administration;
            action(Quotes)
            {
                ApplicationArea = Suite;
                Caption = 'Quotes';
                Image = Quote;
                Promoted = true;
                PromotedCategory = Category7;
                RunObject = Page "Purchase Quotes";
                RunPageLink = "Buy-from Vendor No." = FIELD("No.");
                RunPageView = SORTING("Document Type", "Buy-from Vendor No.");
                ToolTip = 'View a list of ongoing purchase quotes.';
            }
            action(Orders)
            {
                ApplicationArea = Basic, Suite;
                Caption = 'Orders';
                Image = Document;
                Promoted = true;
                PromotedCategory = Category7;
                RunObject = Page "Purchase Order List";
                RunPageLink = "Buy-from Vendor No." = FIELD("No.");
                RunPageView = SORTING("Document Type", "Buy-from Vendor No.");
                ToolTip = 'View a list of ongoing purchase orders for the vendor.';
            }
            action("Return Orders")
            {
                ApplicationArea = PurchReturnOrder;
                Caption = 'Return Orders';
                Image = ReturnOrder;
                Promoted = true;
                PromotedCategory = Category7;
                RunObject = Page "Purchase Return Order List";
                RunPageLink = "Buy-from Vendor No." = FIELD("No.");
                RunPageView = SORTING("Document Type", "Buy-from Vendor No.");
                ToolTip = 'Open the list of ongoing return orders.';
            }
            action("Blanket Orders")
            {
                ApplicationArea = Suite;
                Caption = 'Blanket Orders';
                Image = BlanketOrder;
                RunObject = Page "Blanket Purchase Orders";
                RunPageLink = "Buy-from Vendor No." = FIELD("No.");
                RunPageView = SORTING("Document Type", "Buy-from Vendor No.");
                ToolTip = 'Open the list of ongoing blanket orders.';
            }
        }
        group(History)
        {
            Caption = 'History';
            Image = History;
            action("Ledger E&ntries")
            {
                ApplicationArea = Basic, Suite;
                Caption = 'Ledger E&ntries';
                Image = VendorLedger;
                Promoted = true;
                PromotedCategory = Category9;
                PromotedIsBig = true;
                RunObject = Page "Vendor Ledger Entries";
                RunPageLink = "Vendor No." = FIELD("No.");
                RunPageView = SORTING("Vendor No.")
                              ORDER(Descending);
                ShortCutKey = 'Ctrl+F7';
                ToolTip = 'View the history of transactions that have been posted for the selected record.';
            }
            action(Statistics)
            {
                ApplicationArea = Suite;
                Caption = 'Statistics';
                Image = Statistics;
                Promoted = true;
                PromotedCategory = Category9;
                PromotedIsBig = true;
                RunObject = Page "Vendor Statistics";
                RunPageLink = "No." = FIELD("No."),
                              "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(Purchases)
            {
                ApplicationArea = Basic, Suite;
                Caption = 'Purchases';
                Image = Purchase;
                Promoted = true;
                PromotedCategory = Category7;
                RunObject = Page "Vendor Purchases";
                RunPageLink = "No." = FIELD("No."),
                              "Global Dimension 1 Filter" = FIELD("Global Dimension 1 Filter"),
                              "Global Dimension 2 Filter" = FIELD("Global Dimension 2 Filter");
                ToolTip = 'Shows a summary of vendor 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 "Vendor 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("1099 Statistics")
            {
                ApplicationArea = BasicUS;
                Caption = '1099 Statistics';
                Image = Statistics1099;
                RunObject = Page "Vendor 1099 Statistics";
                RunPageLink = "No." = FIELD("No.");
                ShortCutKey = 'Shift+F11';
                ToolTip = 'View the vendor 1099 statistics that you can use to create 1099 reports and generate the files necessary to submit 1099 information to the Internal Revenue Service (IRS). This information is required to report paid vendor income.';
            }
            action("Statistics by C&urrencies")
            {
                ApplicationArea = Suite;
                Caption = 'Statistics by C&urrencies';
                Image = Currencies;
                RunObject = Page "Vend. Stats. by Curr. Lines";
                RunPageLink = "Vendor 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 vendors that use multiple currencies.';
            }
            action("Item &Tracking Entries")
            {
                ApplicationArea = ItemTracking;
                Caption = 'Item &Tracking Entries';
                Image = ItemTrackingLedger;
                ToolTip = 'View serial or lot numbers that are assigned to items.';

                trigger OnAction()
                var
                    ItemTrackingDocMgt: Codeunit "Item Tracking Doc. Management";
                begin
                    ItemTrackingDocMgt.ShowItemTrackingForEntity(2, "No.", '', '', '');
                end;
            }
        }
        group(ActionGroupCDS)
        {
            Caption = 'Dataverse';
            Image = Administration;
            Visible = CRMIntegrationEnabled or CDSIntegrationEnabled;
            Enabled = (BlockedFilterApplied and (Blocked = Blocked::" ")) or not BlockedFilterApplied;
            action(CDSGotoAccount)
            {
                ApplicationArea = Suite;
                Caption = 'Account';
                Image = CoupledCustomer;
                ToolTip = 'Open the coupled Dataverse account.';

                trigger OnAction()
                var
                    CRMIntegrationManagement: Codeunit "CRM Integration Management";
                begin
                    CRMIntegrationManagement.ShowCRMEntityFromRecordID(RecordId);
                end;
            }
            action(CDSSynchronizeNow)
            {
                AccessByPermission = TableData "CRM Integration Record" = IM;
                ApplicationArea = Suite;
                Caption = 'Synchronize';
                Image = Refresh;
                ToolTip = 'Send or get updated data to or from Dataverse.';

                trigger OnAction()
                var
                    CRMIntegrationManagement: Codeunit "CRM Integration Management";
                begin
                    CRMIntegrationManagement.UpdateOneNow(RecordId);
                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(ManageCDSCoupling)
                {
                    AccessByPermission = TableData "CRM Integration Record" = IM;
                    ApplicationArea = Suite;
                    Caption = 'Set Up Coupling';
                    Image = LinkAccount;
                    ToolTip = 'Create or modify the coupling to a Dataverse account.';

                    trigger OnAction()
                    var
                        CRMIntegrationManagement: Codeunit "CRM Integration Management";
                    begin
                        CRMIntegrationManagement.DefineCoupling(RecordId);
                    end;
                }
                action(DeleteCDSCoupling)
                {
                    AccessByPermission = TableData "CRM Integration Record" = D;
                    ApplicationArea = Suite;
                    Caption = 'Delete Coupling';
                    Enabled = CRMIsCoupledToRecord;
                    Image = UnLinkAccount;
                    ToolTip = 'Delete the coupling to a Dataverse account.';

                    trigger OnAction()
                    var
                        CRMCouplingManagement: Codeunit "CRM Coupling Management";
                    begin
                        CRMCouplingManagement.RemoveCoupling(RecordId);
                    end;
                }
            }
            action(ShowLog)
            {
                ApplicationArea = Suite;
                Caption = 'Synchronization Log';
                Image = Log;
                ToolTip = 'View integration synchronization jobs for vendors.';

                trigger OnAction()
                var
                    CRMIntegrationManagement: Codeunit "CRM Integration Management";
                begin
                    CRMIntegrationManagement.ShowLog(RecordId);
                end;
            }
        }
    }
    area(creation)
    {
        action(NewBlanketPurchaseOrder)
        {
            ApplicationArea = Suite;
            Caption = 'Blanket Purchase Order';
            Image = BlanketOrder;
            Promoted = false;
            //The property 'PromotedCategory' can only be set if the property 'Promoted' is set to 'true'
            //PromotedCategory = Category6;
            RunObject = Page "Blanket Purchase Order";
            RunPageLink = "Buy-from Vendor No." = FIELD("No.");
            RunPageMode = Create;
            ToolTip = 'Create a new blanket purchase order for the vendor.';
        }
        action(NewPurchaseQuote)
        {
            ApplicationArea = Suite;
            Caption = 'Purchase Quote';
            Image = Quote;
            Promoted = false;
            //The property 'PromotedCategory' can only be set if the property 'Promoted' is set to 'true'
            //PromotedCategory = Category6;
            RunObject = Page "Purchase Quote";
            RunPageLink = "Buy-from Vendor No." = FIELD("No.");
            RunPageMode = Create;
            ToolTip = 'Create a new purchase quote for the vendor.';
        }
        action(NewPurchaseInvoice)
        {
            ApplicationArea = Basic, Suite;
            Caption = 'Purchase Invoice';
            Image = NewPurchaseInvoice;
            Promoted = true;
            PromotedCategory = Category6;
            RunObject = Page "Purchase Invoice";
            RunPageLink = "Buy-from Vendor No." = FIELD("No.");
            RunPageMode = Create;
            ToolTip = 'Create a new purchase invoice for items or services.';
            Visible = NOT IsOfficeAddin;
        }
        action(NewPurchaseOrder)
        {
            ApplicationArea = Suite;
            Caption = 'Purchase Order';
            Image = Document;
            Promoted = true;
            PromotedCategory = Category6;
            RunObject = Page "Purchase Order";
            RunPageLink = "Buy-from Vendor No." = FIELD("No.");
            RunPageMode = Create;
            ToolTip = 'Create a new purchase order.';
            Visible = NOT IsOfficeAddin;
        }
        action(NewPurchaseCrMemo)
        {
            ApplicationArea = Basic, Suite;
            Caption = 'Purchase Credit Memo';
            Image = CreditMemo;
            Promoted = true;
            PromotedCategory = Category6;
            RunObject = Page "Purchase Credit Memo";
            RunPageLink = "Buy-from Vendor No." = FIELD("No.");
            RunPageMode = Create;
            ToolTip = 'Create a new purchase credit memo to revert a posted purchase invoice.';
            Visible = NOT IsOfficeAddin;
        }
        action(NewPurchaseReturnOrder)
        {
            ApplicationArea = PurchReturnOrder;
            Caption = 'Purchase Return Order';
            Image = ReturnOrder;
            Promoted = false;
            //The property 'PromotedCategory' can only be set if the property 'Promoted' is set to 'true'
            //PromotedCategory = Category6;
            RunObject = Page "Purchase Return Order";
            RunPageLink = "Buy-from Vendor No." = FIELD("No.");
            RunPageMode = Create;
            ToolTip = 'Create a new purchase return order for the vendor.';
        }
        action(NewPurchaseInvoiceAddin)
        {
            ApplicationArea = Basic, Suite;
            Caption = 'Purchase Invoice';
            Image = NewPurchaseInvoice;
            Promoted = true;
            PromotedCategory = Category6;
            ToolTip = 'Create a new purchase invoice for items or services.';
            Visible = IsOfficeAddin;

            trigger OnAction()
            begin
                CreateAndShowNewInvoice;
            end;
        }
        action(NewPurchaseOrderAddin)
        {
            ApplicationArea = Suite;
            Caption = 'Purchase Order';
            Image = Document;
            Promoted = true;
            PromotedCategory = Category6;
            ToolTip = 'Create a new purchase order.';
            Visible = IsOfficeAddin;

            trigger OnAction()
            begin
                CreateAndShowNewPurchaseOrder;
            end;
        }
        action(NewPurchaseCrMemoAddin)
        {
            ApplicationArea = Basic, Suite;
            Caption = 'Purchase Credit Memo';
            Image = CreditMemo;
            Promoted = true;
            PromotedCategory = Category6;
            ToolTip = 'Create a new purchase credit memo to revert a posted purchase invoice.';
            Visible = IsOfficeAddin;

            trigger OnAction()
            begin
                CreateAndShowNewCreditMemo;
            end;
        }
    }
    area(processing)
    {
        group(Approval)
        {
            Caption = 'Approval';
            action(Approve)
            {
                ApplicationArea = All;
                Caption = 'Approve';
                Image = Approve;
                Promoted = true;
                PromotedCategory = Category4;
                PromotedIsBig = true;
                PromotedOnly = true;
                ToolTip = 'Approve the requested changes.';
                Visible = OpenApprovalEntriesExistCurrUser;

                trigger OnAction()
                var
                    ApprovalsMgmt: Codeunit "Approvals Mgmt.";
                begin
                    ApprovalsMgmt.ApproveRecordApprovalRequest(RecordId);
                end;
            }
            action(Reject)
            {
                ApplicationArea = All;
                Caption = 'Reject';
                Image = Reject;
                Promoted = true;
                PromotedCategory = Category4;
                PromotedIsBig = true;
                PromotedOnly = true;
                ToolTip = 'Reject the approval request.';
                Visible = OpenApprovalEntriesExistCurrUser;

                trigger OnAction()
                var
                    ApprovalsMgmt: Codeunit "Approvals Mgmt.";
                begin
                    ApprovalsMgmt.RejectRecordApprovalRequest(RecordId);
                end;
            }
            action(Delegate)
            {
                ApplicationArea = All;
                Caption = 'Delegate';
                Image = Delegate;
                Promoted = true;
                PromotedCategory = Category4;
                PromotedOnly = true;
                ToolTip = 'Delegate the approval to a substitute approver.';
                Visible = OpenApprovalEntriesExistCurrUser;

                trigger OnAction()
                var
                    ApprovalsMgmt: Codeunit "Approvals Mgmt.";
                begin
                    ApprovalsMgmt.DelegateRecordApprovalRequest(RecordId);
                end;
            }
            action(Comment)
            {
                ApplicationArea = All;
                Caption = 'Comments';
                Image = ViewComments;
                Promoted = true;
                PromotedCategory = Category4;
                PromotedOnly = true;
                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 CanRequestApprovalForFlow;
                Image = SendApprovalRequest;
                Promoted = true;
                PromotedCategory = Category5;
                PromotedIsBig = true;
                ToolTip = 'Request approval to change the record.';

                trigger OnAction()
                var
                    ApprovalsMgmt: Codeunit "Approvals Mgmt.";
                begin
                    if ApprovalsMgmt.CheckVendorApprovalsWorkflowEnabled(Rec) then
                        ApprovalsMgmt.OnSendVendorForApproval(Rec);
                end;
            }
            action(CancelApprovalRequest)
            {
                ApplicationArea = Basic, Suite;
                Caption = 'Cancel Approval Re&quest';
                Enabled = CanCancelApprovalForRecord OR CanCancelApprovalForFlow;
                Image = CancelApprovalRequest;
                Promoted = true;
                PromotedCategory = Category5;
                ToolTip = 'Cancel the approval request.';

                trigger OnAction()
                var
                    ApprovalsMgmt: Codeunit "Approvals Mgmt.";
                begin
                    ApprovalsMgmt.OnCancelVendorApprovalRequest(Rec);
                    WorkflowWebhookManagement.FindAndCancel(RecordId);
                end;
            }
            group(Flow)
            {
                Caption = 'Power Automate';
                action(CreateFlow)
                {
                    ApplicationArea = Basic, Suite;
                    Caption = 'Create a flow';
                    Image = Flow;
                    Promoted = true;
                    PromotedCategory = Category5;
                    ToolTip = 'Create a new flow in Power Automate from a list of relevant flow templates.';
                    Visible = IsSaaS;

                    trigger OnAction()
                    var
                        FlowServiceManagement: Codeunit "Flow Service Management";
                        FlowTemplateSelector: Page "Flow Template Selector";
                    begin
                        // Opens page 6400 where the user can use filtered templates to create new Flows.
                        FlowTemplateSelector.SetSearchText(FlowServiceManagement.GetVendorTemplateFilter);
                        FlowTemplateSelector.Run;
                    end;
                }
                action(SeeFlows)
                {
                    ApplicationArea = Basic, Suite;
                    Caption = 'See my flows';
                    Image = Flow;
                    Promoted = true;
                    PromotedCategory = Category5;
                    RunObject = Page "Flow Selector";
                    ToolTip = 'View and configure Power Automate flows that you created.';
                }
            }
        }
        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 vendor templates.';

                trigger OnAction()
                var
                    VendorTemplMgt: Codeunit "Vendor Templ. Mgt.";
                begin
                    VendorTemplMgt.ShowTemplates();
                end;
            }
            action(ApplyTemplate)
            {
                ApplicationArea = Basic, Suite;
                Caption = 'Apply Template';
                Ellipsis = true;
                Image = ApplyTemplate;
                Promoted = true;
                PromotedCategory = Process;
                PromotedIsBig = true;
                ToolTip = 'Apply a template to update the entity with your standard settings for a certain type of entity.';
                ObsoleteState = Pending;
                ObsoleteReason = 'This functionality will be replaced by other templates.';
                ObsoleteTag = '16.0';

                trigger OnAction()
                var
                    VendorTemplMgt: Codeunit "Vendor Templ. Mgt.";
                begin
                    VendorTemplMgt.UpdateVendorFromTemplate(Rec);
                end;
            }
            action(SaveAsTemplate)
            {
                ApplicationArea = Basic, Suite;
                Caption = 'Save as Template';
                Ellipsis = true;
                Image = Save;
                ToolTip = 'Save the vendor card as a template that can be reused to create new vendor cards. Vendor templates contain preset information to help you fill fields on vendor cards.';
                ObsoleteState = Pending;
                ObsoleteReason = 'This functionality will be replaced by other templates.';
                ObsoleteTag = '16.0';

                trigger OnAction()
                var
                    VendorTemplMgt: Codeunit "Vendor Templ. Mgt.";
                begin
                    VendorTemplMgt.SaveAsTemplate(Rec);
                end;
            }
            action(MergeDuplicate)
            {
                AccessByPermission = TableData "Merge Duplicates Buffer" = RIMD;
                ApplicationArea = Basic, Suite;
                Caption = 'Merge With';
                Ellipsis = true;
                Image = ItemSubstitution;
                ToolTip = 'Merge two vendor 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::Vendor, "No.");
                end;
            }
        }
        action("Create Payments")
        {
            ApplicationArea = Basic, Suite;
            Caption = 'Create Payments';
            Ellipsis = true;
            Image = PaymentJournal;
            Promoted = true;
            PromotedCategory = Process;
            RunObject = Page "Payment Journal";
            ToolTip = 'View or edit the payment journal where you can register payments to vendors.';
        }
        action("Purchase Journal")
        {
            ApplicationArea = Basic, Suite;
            Caption = 'Purchase Journal';
            Image = Journals;
            RunObject = Page "Purchase Journal";
            ToolTip = 'Post any purchase transaction for the vendor. ';
        }
        action(PayVendor)
        {
            ApplicationArea = Basic, Suite;
            Caption = 'Pay Vendor';
            Image = SuggestVendorPayments;
            Promoted = true;
            PromotedCategory = Process;
            PromotedIsBig = true;
            RunObject = Page "Vendor Ledger Entries";
            RunPageLink = "Vendor No." = FIELD("No."),
                          "Remaining Amount" = FILTER(< 0),
                          "Applies-to ID" = FILTER(''),
                          "Document Type" = FILTER(Invoice);
            ToolTip = 'Opens vendor ledger entries with invoices that have not been paid yet.';
        }
        action(WordTemplate)
        {
            ApplicationArea = All;
            Caption = 'Word Template';
            ToolTIp = 'Apply a Word template on the vendor.';
            Image = Word;
            Promoted = true;
            PromotedCategory = Category9;

            trigger OnAction()
            var
                Vendor: Record Vendor;
                WordTemplateSelectionWizard: Page "Word Template Selection Wizard";
            begin
                CurrPage.SetSelectionFilter(Vendor);
                WordTemplateSelectionWizard.SetData(Vendor);
                WordTemplateSelectionWizard.RunModal();
            end;
        }
        action(Email)
        {
            ApplicationArea = All;
            Caption = 'Contact by Email';
            Image = Email;
            Promoted = true;
            PromotedCategory = Category9;
            ToolTip = 'Send an email to this vendor.';

            trigger OnAction()
            var
                Email: Codeunit Email;
                EmailMessage: Codeunit "Email Message";
            begin
                EmailMessage.Create(Rec."E-Mail", '', '', true);
                Email.AddRelation(EmailMessage, Database::Vendor, Rec.SystemId, Enum::"Email Relation Type"::"Primary Source");
                Email.OpenInEditorModally(EmailMessage);
            end;
        }
        group("Incoming Documents")
        {
            Caption = 'Incoming Documents';
            Image = SendApprovalRequest;
            action(SendToIncomingDocuments)
            {
                ApplicationArea = Basic, Suite;
                Caption = 'Send to Incoming Documents';
                Ellipsis = true;
                Enabled = SendToIncomingDocEnabled;
                Image = SendElectronicDocument;
                Promoted = true;
                PromotedCategory = Category8;
                PromotedIsBig = true;
                ToolTip = 'Send to Incoming Documents';
                Visible = SendToIncomingDocumentVisible;

                trigger OnAction()
                begin
                    OfficeMgt.InitiateSendToIncomingDocuments("No.");
                end;
            }
            action(SendToOCR)
            {
                ApplicationArea = Basic, Suite;
                Caption = 'Send To OCR';
                Ellipsis = true;
                Enabled = SendToOCREnabled;
                Image = SendElectronicDocument;
                Promoted = true;
                PromotedCategory = Category8;
                PromotedIsBig = true;
                ToolTip = 'Send To OCR';
                Visible = SendToOCRVisible;

                trigger OnAction()
                begin
                    OfficeMgt.InitiateSendToOCR("No.");
                end;
            }
            action(SendIncomingDocApprovalRequest)
            {
                AccessByPermission = TableData "Approval Entry" = I;
                ApplicationArea = Basic, Suite;
                Caption = 'Send A&pproval Request';
                Image = SendApprovalRequest;
                Promoted = true;
                PromotedCategory = Category8;
                PromotedOnly = true;
                ToolTip = 'Request approval to change the record.';
                Visible = SendIncomingDocApprovalRequestVisible;

                trigger OnAction()
                begin
                    OfficeMgt.InitiateSendApprovalRequest("No.");
                end;
            }
        }
    }
    area(reporting)
    {
        action("Vendor - Balance to Date")
        {
            ApplicationArea = Basic, Suite;
            Caption = 'Vendor - Balance to Date';
            Image = "Report";
            Promoted = false;
            //The property 'PromotedCategory' can only be set if the property 'Promoted' is set to 'true'
            //PromotedCategory = "Report";
            ToolTip = 'View a detail balance for selected vendors.';

            trigger OnAction()
            begin
                RunReport(REPORT::"Vendor - Balance to Date");
            end;
        }
        action("Open Vendor Entries")
        {
            ApplicationArea = Basic, Suite;
            Caption = 'Open Vendor Entries';
            Image = "Report";
            Promoted = true;
            PromotedCategory = "Report";
            PromotedOnly = true;
            ToolTip = 'View open vendor entries. This report lists the open entries for each vendor, and shows the age (days overdue) and remaining amount due in the transaction currency for each open entry.';

            trigger OnAction()
            begin
                RunReport(REPORT::"Open Vendor Entries");
            end;
        }
        action("Projected Cash Payments")
        {
            ApplicationArea = Basic, Suite;
            Caption = 'Projected Cash Payments';
            Image = PaymentForecast;
            Promoted = false;
            //The property 'PromotedCategory' can only be set if the property 'Promoted' is set to 'true'
            //PromotedCategory = "Report";
            ToolTip = 'View projections about what future payments to vendors will be. Current orders are used to generate a chart, using the specified time period and start date, to break down future payments. The report also includes a total balance column.';

            trigger OnAction()
            begin
                RunReport(REPORT::"Projected Cash Payments");
            end;
        }
        action("Vendor 1099 Div")
        {
            ApplicationArea = BasicUS;
            Caption = 'Vendor 1099 Div';
            Image = "Report";
            Promoted = false;
            //The property 'PromotedCategory' can only be set if the property 'Promoted' is set to 'true'
            //PromotedCategory = "Report";
            ToolTip = 'View the federal form 1099-DIV for dividends and distribution.';

            trigger OnAction()
            begin
                RunReport(REPORT::"Vendor 1099 Div");
            end;
        }
        action("Vendor 1099 Int")
        {
            ApplicationArea = BasicUS;
            Caption = 'Vendor 1099 Int';
            Image = "Report";
            Promoted = false;
            //The property 'PromotedCategory' can only be set if the property 'Promoted' is set to 'true'
            //PromotedCategory = "Report";
            ToolTip = 'View the federal form 1099-INT for interest income.';

            trigger OnAction()
            begin
                RunReport(REPORT::"Vendor 1099 Int");
            end;
        }
        action("Vendor 1099 Misc")
        {
            ApplicationArea = BasicUS;
            Caption = 'Vendor 1099 Misc';
            Image = "Report";
            Promoted = false;
            //The property 'PromotedCategory' can only be set if the property 'Promoted' is set to 'true'
            //PromotedCategory = "Report";
            ToolTip = 'View the federal form 1099-MISC for miscellaneous income.';

            trigger OnAction()
            var
                IRS1099Management: Codeunit "IRS 1099 Management";
            begin
                IRS1099Management.Run1099MiscReport();
            end;
        }
        action("Vendor 1099 Information")
        {
            ApplicationArea = BasicUS;
            Caption = 'Vendor 1099 Information';
            Image = "Report";
            Promoted = false;
            //The property 'PromotedCategory' can only be set if the property 'Promoted' is set to 'true'
            //PromotedCategory = "Report";
            ToolTip = 'View the vendors'' 1099 information. The report includes all 1099 information for the vendors that have been set up using the IRS 1099 Form-Box table. This includes only amounts that have been paid. It does not include amounts billed but not yet paid. You must enter a date filter before you can print this report.';

            trigger OnAction()
            begin
                RunReport(REPORT::"Vendor 1099 Information");
            end;
        }
        action("Vendor/Item Statistics")
        {
            ApplicationArea = Basic, Suite;
            Caption = 'Vendor/Item Statistics';
            Image = "Report";
            Promoted = false;
            //The property 'PromotedCategory' can only be set if the property 'Promoted' is set to 'true'
            //PromotedCategory = "Report";
            ToolTip = 'View a complete or partial catalog of which vendors offer which items.';

            trigger OnAction()
            begin
                RunReport(REPORT::"Vendor/Item Statistics");
            end;
        }
        action("Vendor/Item Catalog")
        {
            ApplicationArea = Basic, Suite;
            Caption = 'Vendor/Item Catalog';
            Image = "Report";
            Promoted = false;
            //The property 'PromotedCategory' can only be set if the property 'Promoted' is set to 'true'
            //PromotedCategory = "Report";
            ToolTip = 'View a complete or partial catalog of which vendors offer which items.';

            trigger OnAction()
            begin
                ItemVendor.SetRange("Vendor No.", "No.");
                REPORT.RunModal(REPORT::"Item/Vendor Catalog", true, true, ItemVendor);
            end;
        }
    }
}

trigger OnAfterGetCurrRecord()
var
    CRMCouplingManagement: Codeunit "CRM Coupling Management";
begin
    CreateVendorFromTemplate;
    ActivateFields;
    OpenApprovalEntriesExistCurrUser := ApprovalsMgmt.HasOpenApprovalEntriesForCurrentUser(RecordId);
    OpenApprovalEntriesExist := ApprovalsMgmt.HasOpenApprovalEntries(RecordId);
    ShowWorkflowStatus := CurrPage.WorkflowStatus.PAGE.SetFilterOnWorkflowRecord(RecordId);
    CanCancelApprovalForRecord := ApprovalsMgmt.CanCancelApprovalForRecord(RecordId);
    WorkflowWebhookManagement.GetCanRequestAndCanCancel(RecordId, CanRequestApprovalForFlow, CanCancelApprovalForFlow);

    if "No." <> '' then
        CurrPage.AgedAccPayableChart.PAGE.UpdateChartForVendor("No.");
    if Rec.GetFilter("Date Filter") = '' then
        SetRange("Date Filter", 0D, WorkDate());
    CRMIsCoupledToRecord := CRMIntegrationEnabled or CDSIntegrationEnabled;
    if CRMIsCoupledToRecord then
        CRMIsCoupledToRecord := CRMCouplingManagement.IsRecordCoupledToCRM(RecordId);
end;

trigger OnInit()
begin
    ContactEditable := true;
end;

trigger OnNewRecord(BelowxRec: Boolean)
var
    DocumentNoVisibility: Codeunit DocumentNoVisibility;
begin
    if GuiAllowed then
        if "No." = '' then
            if DocumentNoVisibility.VendorNoSeriesIsDefault then
                NewMode := true;
end;

trigger OnOpenPage()
var
    IntegrationTableMapping: Record "Integration Table Mapping";
    GLSetup: Record "General Ledger Setup";
    EnvironmentInfo: Codeunit "Environment Information";
    CRMIntegrationManagement: Codeunit "CRM Integration Management";
    ItemReferenceMgt: Codeunit "Item Reference Management";
    PriceCalculationMgt: Codeunit "Price Calculation Mgt.";
begin
    ActivateFields();
    IsOfficeAddin := OfficeMgt.IsAvailable();
    SetNoFieldVisible();
    IsSaaS := EnvironmentInfo.IsSaaS();
    GLSetup.Get();
    UseVAT := GLSetup."VAT in Use";
    CRMIntegrationEnabled := CRMIntegrationManagement.IsCRMIntegrationEnabled();
    CDSIntegrationEnabled := CRMIntegrationManagement.IsCDSIntegrationEnabled();
    if CRMIntegrationEnabled or CDSIntegrationEnabled then
        if IntegrationTableMapping.Get('VENDOR') then
            BlockedFilterApplied := IntegrationTableMapping.GetTableFilter().Contains('Field39=1(0)');
    ExtendedPriceEnabled := PriceCalculationMgt.IsExtendedPriceCalculationEnabled();

    SetOverReceiptControlsVisibility();
    ItemReferenceVisible := ItemReferenceMgt.IsEnabled();
end;

var
    ItemVendor: Record "Item Vendor";
    OfficeMgt: Codeunit "Office Management";
    CalendarMgmt: Codeunit "Calendar Management";
    PaymentToleranceMgt: Codeunit "Payment Tolerance Management";
    WorkflowWebhookManagement: Codeunit "Workflow Webhook Management";
    ApprovalsMgmt: Codeunit "Approvals Mgmt.";
    Text001: Label 'Do you want to allow payment tolerance for entries that are currently open?';
    Text002: Label 'Do you want to remove payment tolerance from entries that are currently open?';
    FormatAddress: Codeunit "Format Address";
    [InDataSet]
    ContactEditable: Boolean;
    OpenApprovalEntriesExistCurrUser: Boolean;
    OpenApprovalEntriesExist: Boolean;
    ShowWorkflowStatus: Boolean;
    ShowMapLbl: Label 'Show on Map';
    IsOfficeAddin: Boolean;
    CanCancelApprovalForRecord: Boolean;
    UseVAT: Boolean;
    SendToOCREnabled: Boolean;
    SendToOCRVisible: Boolean;
    SendToIncomingDocEnabled: Boolean;
    SendIncomingDocApprovalRequestVisible: Boolean;
    SendToIncomingDocumentVisible: Boolean;
    NoFieldVisible: Boolean;
    NewMode: Boolean;
    CanRequestApprovalForFlow: Boolean;
    CanCancelApprovalForFlow: Boolean;
    IsSaaS: Boolean;
    IsCountyVisible: Boolean;
    CRMIntegrationEnabled: Boolean;
    CDSIntegrationEnabled: Boolean;
    CRMIsCoupledToRecord: Boolean;
    BlockedFilterApplied: Boolean;
    ExtendedPriceEnabled: Boolean;
    OverReceiptAllowed: Boolean;
    [InDataSet]
    ItemReferenceVisible: Boolean;

local procedure ActivateFields()
//NPO begin
var
    IsHandled: Boolean;
//NPO end
begin
    //NPO begin
    IsHandled := false;
    OnBeforeActivateFields(IsHandled, IsCountyVisible, FormatAddress);
    if not IsHandled then begin
        //NPO end        
        ContactEditable := "Primary Contact No." = '';
        IsCountyVisible := FormatAddress.UseCounty("Country/Region Code");
        if OfficeMgt.IsAvailable then
            ActivateIncomingDocumentsFields;
        //NPO begin
    end;
    //NPO end            
end;

local procedure ContactOnAfterValidate()
begin
    ActivateFields;
end;

procedure RunReport(ReportNumber: Integer)
var
    Vendor: Record Vendor;
begin
    Vendor.SetRange("No.", "No.");
    REPORT.RunModal(ReportNumber, true, true, Vendor);
end;

local procedure ActivateIncomingDocumentsFields()
var
    IncomingDocument: Record "Incoming Document";
begin
    if OfficeMgt.OCRAvailable then begin
        SendToIncomingDocumentVisible := true;
        SendToIncomingDocEnabled := OfficeMgt.EmailHasAttachments;
        SendToOCREnabled := OfficeMgt.EmailHasAttachments;
        SendToOCRVisible := IncomingDocument.OCRIsEnabled and not IsIncomingDocApprovalsWorkflowEnabled;
        SendIncomingDocApprovalRequestVisible := IsIncomingDocApprovalsWorkflowEnabled;
    end;
end;

local procedure IsIncomingDocApprovalsWorkflowEnabled(): Boolean
var
    WorkflowEventHandling: Codeunit "Workflow Event Handling";
    WorkflowDefinition: Query "Workflow Definition";
begin
    WorkflowDefinition.SetRange(Table_ID, DATABASE::"Incoming Document");
    WorkflowDefinition.SetRange(Entry_Point, true);
    WorkflowDefinition.SetRange(Enabled, true);
    WorkflowDefinition.SetRange(Type, WorkflowDefinition.Type::"Event");
    WorkflowDefinition.SetRange(Function_Name, WorkflowEventHandling.RunWorkflowOnSendIncomingDocForApprovalCode);
    WorkflowDefinition.Open;
    while WorkflowDefinition.Read do
        exit(true);

    exit(false);
end;

local procedure CreateVendorFromTemplate()
var
    Vendor: Record Vendor;
    VendorTemplMgt: Codeunit "Vendor Templ. Mgt.";
begin
    OnBeforeCreateVendorFromTemplate(NewMode, Vendor);

    if not NewMode then
        exit;
    NewMode := false;

    if VendorTemplMgt.InsertVendorFromTemplate(Vendor) then begin
        VerifyVatRegNo(Vendor);
        Copy(Vendor);
        CurrPage.Update();
    end else
        if VendorTemplMgt.TemplatesAreNotEmpty() then
            CurrPage.Close;
end;

local procedure SetNoFieldVisible()
var
    DocumentNoVisibility: Codeunit DocumentNoVisibility;
begin
    NoFieldVisible := DocumentNoVisibility.VendorNoIsVisible;
end;

local procedure SetOverReceiptControlsVisibility()
var
    OverReceiptMgt: Codeunit "Over-Receipt Mgt.";
begin
    OverReceiptAllowed := OverReceiptMgt.IsOverReceiptAllowed();
end;

local procedure VerifyVatRegNo(var Vendor: Record Vendor)
var
    VATRegNoSrvConfig: Record "VAT Reg. No. Srv Config";
    EUVATRegistrationNoCheck: Page "EU VAT Registration No Check";
    VendorRecRef: RecordRef;
begin
    if VATRegNoSrvConfig.VATRegNoSrvIsEnabled then
        if Vendor."Validate EU Vat Reg. No." then begin
            EUVATRegistrationNoCheck.SetRecordRef(Vendor);
            Commit();
            EUVATRegistrationNoCheck.RunModal;
            EUVATRegistrationNoCheck.GetRecordRef(VendorRecRef);
            VendorRecRef.SetTable(Vendor);
        end;
end;

[IntegrationEvent(false, false)]
local procedure OnBeforeCreateVendorFromTemplate(var NewMode: Boolean; var Vendor: Record Vendor)
begin
end;

//NPO begin
[IntegrationEvent(true, false)]
local procedure OnBeforeActivateFields(var IsHandled: Boolean; var IsCountyVisible: Boolean; var FormatAddress: Codeunit "Format Address")
begin
end;
//NPO end    

}

JesperSchulz commented 3 years ago

Thanks for reporting this. We agree, and we’ll publish a fix asap, either in an update for the current version or in the next major release. Please do not reply to this, as we do not monitor closed issues. If you have follow-up questions or requests, please create a new issue where you reference this one.