Skip to content

Extending pages with the Document Dispatch Factbox

This documentation describes how to expand a page in Business Central with the Document Dispatch Factbox. The factbox is used to get an overview of the configured sub-items, such as the availability of dispatch options, and to send documents directly when set up correctly.

A complete page extension for Document Dispatch consists of two parts:

  1. Layout – The factbox (SIM_EDS FB) is added to the FactBoxes area of the page.
  2. Actions – The Document Dispatch actions (e.g. Send, Download, Schedule) are integrated as an action group in the page's ribbon.

Starting with Version 25, additional actions were introduced that do not exist in BC24. The code examples are therefore divided by version.

There are two ways to include the extension:

  1. When using a custom page, the code can be added directly to the page.
  2. If you want to extend existing pages, you can create a page extension that executes the code.

Requirements

The following requirements must be met:

  • The Document Dispatch module must be licensed.
  • CORE must be available in the extension as a reference.
  • Document Dispatch must be available in the extension as a reference.

Extension of a Business Central page with the Document Dispatch Factbox

Card
- For Document Dispatch from BC24
pageextension 5487161 "SIM_EDS PostedSalesInvoiceExt" extends "Posted Sales Invoice" //132
{
    layout
    {
        addfirst(FactBoxes)
        {
            part(SIM_EDSFB; "SIM_EDS FB")
            {
                ApplicationArea = All;
            }
        }
    }
    actions
    {
        addafter(Category_Category13)
        {
            group(SIM_EDS_Actions_Promoted)
            {
                Caption = 'Document Dispatch';
                ShowAs = Standard;
                Image = SendTo;
                Visible = GlobalIsUserRegisteredBoolean;

                actionref(SIM_EDS_FB_Send_Promoted; SIM_EDS_FB_Send) { }
                actionref(SIM_EDS_FB_SendDialog_Promoted; SIM_EDS_FB_SendDialog) { }
                actionref(SIM_EDS_FB_DownloadAction_Promoted; SIM_EDS_FB_DownloadAction) { }
                actionref(SIM_EDS_FB_Schedule_Promoted; SIM_EDS_FB_Schedule) { }
                actionref(SIM_EDS_FB_Cancel_Promoted; SIM_EDS_FB_Cancel) { }
                actionref(SIM_EDS_FB_OneDrive_Promoted; SIM_EDS_FB_OneDrive) { }
                actionref(SIM_EDS_FB_SetupBP_Promoted; SIM_EDS_FB_SetupBP) { }
                actionref(SIM_EDS_FB_ConfigureBP_Promoted; SIM_EDS_FB_ConfigureBP) { }
            }
        }
        addafter("&Navigate")
        {
            group(SIM_EDS_FB_Actions)
            {
                Caption = 'Document Dispatch';
                Visible = GlobalIsUserRegisteredBoolean;

                action(SIM_EDS_FB_Send)
                {
                    Caption = 'Send';
                    ToolTip = 'Send the pre-configured documents to the business partner for the current entry.';
                    Image = Email;
                    ApplicationArea = All;
                    Ellipsis = true;
                    Visible = GlobalMultipleOutputTypesExistsBoolean;

                    trigger OnAction()
                    var
                        LocalCodeunitSIMEDSQueueMgt: Codeunit "SIM_EDS Queue Mgt";
                        LocalRecordRef: RecordRef;
                    begin
                        LocalRecordRef.GetTable(Rec);
                        LocalCodeunitSIMEDSQueueMgt.SendEDS(LocalRecordRef, true, false, '');
                        LocalRecordRef.Close();
                        CurrPage.SIM_EDSFB.Page.SetVariant(Rec);
                    end;
                }
                action(SIM_EDS_FB_SendDialog)
                {
                    Caption = 'Send Dialog';
                    ToolTip = 'Edit or personalize the email before sending it to the business partner.';
                    Image = Email;
                    ApplicationArea = All;
                    Ellipsis = true;
                    Visible = GlobalMultipleOutputTypesExistsBoolean;

                    trigger OnAction()
                    begin
                        CurrPage.SIM_EDSFB.Page.SendDialog();
                    end;
                }
                action(SIM_EDS_FB_DownloadAction)
                {
                    Caption = 'Download';
                    ToolTip = 'Download the pre-configured documents to the Document Dispatch business partner that have the output type "Download" for the current entry.';
                    Image = Download;
                    ApplicationArea = All;
                    Ellipsis = true;
                    Visible = GlobalSelectedContainsDownloadBoolean;

                    trigger OnAction()
                    begin
                        CurrPage.SIM_EDSFB.Page.Download();
                    end;
                }
                action(SIM_EDS_FB_Schedule)
                {
                    Caption = 'Schedule';
                    ToolTip = 'Open the settings for scheduled dispatch for the current entry.';
                    Image = ChangeDate;
                    ApplicationArea = All;
                    Ellipsis = true;

                    trigger OnAction()
                    begin
                        CurrPage.SIM_EDSFB.Page.ScheduleWizard();
                    end;
                }
                action(SIM_EDS_FB_Cancel)
                {
                    Caption = 'Cancel';
                    ToolTip = 'Cancel the dispatch for the current entry. If the dispatch is set to scheduled or delayed dispatch and the dispatch has not yet been executed, cancel the dispatch.';
                    Image = Cancel;
                    ApplicationArea = All;
                    Visible = GlobalCancelVisibleBoolean;

                    trigger OnAction()
                    begin
                        CurrPage.SIM_EDSFB.Page.Cancel();
                    end;
                }
                action(SIM_EDS_FB_OneDrive)
                {
                    Caption = 'Share through OneDrive';
                    ToolTip = 'Share the current record through a OneDrive link.';
                    Ellipsis = true;
                    Image = Share;
                    Visible = GlobalSelectedContainsDownloadBoolean;
                    ApplicationArea = All;

                    trigger OnAction()
                    begin
                        CurrPage.SIM_EDSFB.Page.OneDriveShare('Posted Sales Invoice');
                    end;
                }
                action(SIM_EDS_FB_SetupBP)
                {
                    ApplicationArea = All;
                    Caption = 'Set up Business Partner';
                    ToolTip = 'Open the wizard to set up this Document Dispatch business partner for electronic dispatch, if the business partner is not activated yet.';
                    Image = SalesPerson;
                    Visible = GlobalBusinessPartnerSetupVisibleBoolean;
                    Ellipsis = true;

                    trigger OnAction()
                    begin
                        CurrPage.SIM_EDSFB.Page.SetupBusinessPartner();
                    end;
                }
                action(SIM_EDS_FB_ConfigureBP)
                {
                    ApplicationArea = All;
                    Caption = 'View/Configure Business Partner';
                    Image = EditCustomer;
                    Visible = GlobalIsBPConfigurationActiveBoolean;
                    ToolTip = 'If there is an Document Dispatch business partner setup, the Document Dispatch business partner setup page will be opened.';

                    trigger OnAction()
                    begin
                        CurrPage.SIM_EDSFB.Page.ConfigureBusinessPartner();
                    end;
                }
            }
        }
    }

    trigger OnOpenPage()
    begin
        GlobalIsUserRegisteredBoolean := CurrPage.SIM_EDSFB.Page.IsUserRegistered();
    end;

    trigger OnAfterGetCurrRecord()
    var
        LocalRecordSIMEDSSetup: Record "SIM_EDS Setup";
        LocalCodeunitSIMCOREMgt: Codeunit "SIM_CORE Mgt";
    begin
        if not LocalCodeunitSIMCOREMgt.CheckPermissions(UserSecurityId(), 'SIM_EDS USER | SIM_EDS ADMIN | SUPER') then exit;
        if not LocalRecordSIMEDSSetup.Get() then exit;
        CurrPage.SIM_EDSFB.Page.SetVariant(Rec);

        GlobalMultipleOutputTypesExistsBoolean := CurrPage.SIM_EDSFB.Page.HasMultipleOutputTypes();
        GlobalSelectedContainsDownloadBoolean := CurrPage.SIM_EDSFB.Page.HasDownload();
        GlobalCancelVisibleBoolean := CurrPage.SIM_EDSFB.Page.IsCancelVisible();
        GlobalBusinessPartnerSetupVisibleBoolean := CurrPage.SIM_EDSFB.Page.IsBusinessPartnerSetupVisible();
        GlobalIsBPConfigurationActiveBoolean := CurrPage.SIM_EDSFB.Page.IsBPConfigurationActive();
    end;

    var
        GlobalSelectedContainsDownloadBoolean: Boolean;
        GlobalIsUserRegisteredBoolean: Boolean;
        GlobalMultipleOutputTypesExistsBoolean: Boolean;
        GlobalCancelVisibleBoolean: Boolean;
        GlobalBusinessPartnerSetupVisibleBoolean: Boolean;
        GlobalIsBPConfigurationActiveBoolean: Boolean;
}
- For Document Dispatch from BC25 and above
pageextension 5487161 "SIM_EDS PostedSalesInvoiceExt" extends "Posted Sales Invoice" //132
{
    layout
    {
        addfirst(FactBoxes)
        {
            part(SIM_EDSFB; "SIM_EDS FB")
            {
                ApplicationArea = All;
            }
        }
    }
    actions
    {
        addafter(Category_Category13)
        {
            group(SIM_EDS_Actions_Promoted)
            {
                Caption = 'Document Dispatch';
                ShowAs = Standard;
                Image = SendTo;
                Visible = GlobalIsUserRegisteredBoolean;

                actionref(SIM_EDS_FB_Send_Promoted; SIM_EDS_FB_Send) { }
                actionref(SIM_EDS_FB_SendDialog_Promoted; SIM_EDS_FB_SendDialog) { }
                actionref(SIM_EDS_FB_DownloadAction_Promoted; SIM_EDS_FB_DownloadAction) { }
                actionref(SIM_EDS_FB_AddToPrintList_Promoted; SIM_EDS_FB_AddToPrintList) { }
                actionref(SIM_EDS_FB_Schedule_Promoted; SIM_EDS_FB_Schedule) { }
                actionref(SIM_EDS_FB_Cancel_Promoted; SIM_EDS_FB_Cancel) { }
                actionref(SIM_EDS_FB_OneDrive_Promoted; SIM_EDS_FB_OneDrive) { }
                actionref(SIM_EDS_FB_SetupBP_Promoted; SIM_EDS_FB_SetupBP) { }
                actionref(SIM_EDS_FB_ConfigureBP_Promoted; SIM_EDS_FB_ConfigureBP) { }
            }
        }
        addafter("&Navigate")
        {
            group(SIM_EDS_FB_Actions)
            {
                Caption = 'Document Dispatch';
                Visible = GlobalIsUserRegisteredBoolean;

                action(SIM_EDS_FB_Send)
                {
                    Caption = 'Send';
                    ToolTip = 'Send the pre-configured documents to the business partner for the current entry.';
                    Image = Email;
                    ApplicationArea = All;
                    Ellipsis = true;
                    Visible = GlobalMultipleOutputTypesExistsBoolean or GlobalIsEPostBoolean;

                    trigger OnAction()
                    var
                        LocalCodeunitSIMEDSQueueMgt: Codeunit "SIM_EDS Queue Mgt";
                        LocalRecordRef: RecordRef;
                    begin
                        LocalRecordRef.GetTable(Rec);
                        LocalCodeunitSIMEDSQueueMgt.SendEDS(LocalRecordRef, true, false, '');
                        LocalRecordRef.Close();
                        CurrPage.SIM_EDSFB.Page.SetVariant(Rec);
                    end;
                }
                action(SIM_EDS_FB_SendDialog)
                {
                    Caption = 'Send Dialog';
                    ToolTip = 'Edit or personalize the email before sending it to the business partner.';
                    Image = Email;
                    ApplicationArea = All;
                    Ellipsis = true;
                    Visible = GlobalMultipleOutputTypesExistsBoolean or GlobalIsEPostBoolean;

                    trigger OnAction()
                    begin
                        CurrPage.SIM_EDSFB.Page.SendDialog();
                    end;
                }
                action(SIM_EDS_FB_DownloadAction)
                {
                    Caption = 'Download';
                    ToolTip = 'Download the pre-configured documents to the Document Dispatch business partner that have the output type "Download" for the current entry.';
                    Image = Download;
                    ApplicationArea = All;
                    Ellipsis = true;
                    Visible = GlobalSelectedContainsDownloadBoolean;

                    trigger OnAction()
                    begin
                        CurrPage.SIM_EDSFB.Page.Download();
                    end;
                }
                action(SIM_EDS_FB_AddToPrintList)
                {
                    Caption = 'Add to Print List';
                    ToolTip = 'Add the current entry to the Print List for batch printing or merging.';
                    Image = Print;
                    ApplicationArea = All;
                    Visible = GlobalIsPrintListBoolean;

                    trigger OnAction()
                    begin
                        CurrPage.SIM_EDSFB.Page.AddToPrintList();
                    end;
                }
                action(SIM_EDS_FB_Schedule)
                {
                    Caption = 'Schedule';
                    ToolTip = 'Open the settings for scheduled dispatch for the current entry.';
                    Image = ChangeDate;
                    ApplicationArea = All;
                    Ellipsis = true;

                    trigger OnAction()
                    begin
                        CurrPage.SIM_EDSFB.Page.ScheduleWizard();
                    end;
                }
                action(SIM_EDS_FB_Cancel)
                {
                    Caption = 'Cancel';
                    ToolTip = 'Cancel the dispatch for the current entry. If the dispatch is set to scheduled or delayed dispatch and the dispatch has not yet been executed, cancel the dispatch.';
                    Image = Cancel;
                    ApplicationArea = All;
                    Visible = GlobalCancelVisibleBoolean;

                    trigger OnAction()
                    begin
                        CurrPage.SIM_EDSFB.Page.Cancel();
                    end;
                }
                action(SIM_EDS_FB_OneDrive)
                {
                    Caption = 'Share through OneDrive';
                    ToolTip = 'Share the current record through a OneDrive link.';
                    Ellipsis = true;
                    Image = Share;
                    Visible = GlobalSelectedContainsDownloadBoolean;
                    ApplicationArea = All;

                    trigger OnAction()
                    begin
                        CurrPage.SIM_EDSFB.Page.OneDriveShare('Posted Sales Invoice');
                    end;
                }
                action(SIM_EDS_FB_SetupBP)
                {
                    ApplicationArea = All;
                    Caption = 'Set up Business Partner';
                    ToolTip = 'Open the wizard to set up this Document Dispatch business partner for electronic dispatch, if the business partner is not activated yet.';
                    Image = SalesPerson;
                    Visible = GlobalBusinessPartnerSetupVisibleBoolean;
                    Ellipsis = true;

                    trigger OnAction()
                    begin
                        CurrPage.SIM_EDSFB.Page.SetupBusinessPartner();
                    end;
                }
                action(SIM_EDS_FB_ConfigureBP)
                {
                    ApplicationArea = All;
                    Caption = 'View/Configure Business Partner';
                    Image = EditCustomer;
                    Visible = GlobalIsBPConfigurationActiveBoolean;
                    ToolTip = 'If there is an Document Dispatch business partner setup, the Document Dispatch business partner setup page will be opened.';

                    trigger OnAction()
                    begin
                        CurrPage.SIM_EDSFB.Page.ConfigureBusinessPartner();
                    end;
                }
            }
        }
    }

    trigger OnOpenPage()
    begin
        GlobalIsUserRegisteredBoolean := CurrPage.SIM_EDSFB.Page.IsUserRegistered();
    end;

    trigger OnAfterGetCurrRecord()
    var
        LocalRecordSIMEDSSetup: Record "SIM_EDS Setup";
        LocalCodeunitSIMCOREMgt: Codeunit "SIM_CORE Mgt";
    begin
        if not LocalCodeunitSIMCOREMgt.CheckPermissions(UserSecurityId(), 'SIM_EDS USER | SIM_EDS ADMIN | SUPER') then exit;
        if not LocalRecordSIMEDSSetup.Get() then exit;
        CurrPage.SIM_EDSFB.Page.SetVariant(Rec);

        GlobalMultipleOutputTypesExistsBoolean := CurrPage.SIM_EDSFB.Page.HasMultipleOutputTypes();
        GlobalSelectedContainsDownloadBoolean := CurrPage.SIM_EDSFB.Page.HasDownload();
        GlobalIsEPostBoolean := CurrPage.SIM_EDSFB.Page.HasEPost();
        GlobalIsPrintListBoolean := CurrPage.SIM_EDSFB.Page.HasPrintList();
        GlobalCancelVisibleBoolean := CurrPage.SIM_EDSFB.Page.IsCancelVisible();
        GlobalBusinessPartnerSetupVisibleBoolean := CurrPage.SIM_EDSFB.Page.IsBusinessPartnerSetupVisible();
        GlobalIsBPConfigurationActiveBoolean := CurrPage.SIM_EDSFB.Page.IsBPConfigurationActive();
    end;

    var
        GlobalSelectedContainsDownloadBoolean: Boolean;
        GlobalIsUserRegisteredBoolean: Boolean;
        GlobalMultipleOutputTypesExistsBoolean: Boolean;
        GlobalIsEPostBoolean: Boolean;
        GlobalIsPrintListBoolean: Boolean;
        GlobalCancelVisibleBoolean: Boolean;
        GlobalBusinessPartnerSetupVisibleBoolean: Boolean;
        GlobalIsBPConfigurationActiveBoolean: Boolean;
}
List
- For Document Dispatch from BC24
pageextension 5487166 "SIM_EDS PostedSalesInvoicesExt" extends "Posted Sales Invoices" //143
{
    layout
    {
        addfirst(FactBoxes)
        {
            part(SIM_EDSFB; "SIM_EDS FB")
            {
                ApplicationArea = All;
            }
        }
    }
    actions
    {
        addafter(Category_Category5)
        {
            group(SIM_EDS_Actions_Promoted)
            {
                Caption = 'Document Dispatch';
                ShowAs = Standard;
                Image = SendTo;
                Visible = GlobalIsUserRegisteredBoolean;

                actionref(SIM_EDS_FB_Send_Promoted; SIM_EDS_FB_Send) { }
                actionref(SIM_EDS_FB_SendDialog_Promoted; SIM_EDS_FB_SendDialog) { }
                actionref(SIM_EDS_FB_DownloadAction_Promoted; SIM_EDS_FB_DownloadAction) { }
                actionref(SIM_EDS_FB_Schedule_Promoted; SIM_EDS_FB_Schedule) { }
                actionref(SIM_EDS_FB_Cancel_Promoted; SIM_EDS_FB_Cancel) { }
                actionref(SIM_EDS_FB_Multimail_Promoted; SIM_EDS_FB_Multimail) { }
                actionref(SIM_EDS_FB_OneDrive_Promoted; SIM_EDS_FB_OneDrive) { }
                actionref(SIM_EDS_FB_SetupBP_Promoted; SIM_EDS_FB_SetupBP) { }
                actionref(SIM_EDS_FB_ConfigureBP_Promoted; SIM_EDS_FB_ConfigureBP) { }
            }
        }

        addlast(processing)
        {
            group(SIM_EDS_FB_Actions)
            {
                Caption = 'Document Dispatch';
                Visible = GlobalIsUserRegisteredBoolean;

                action(SIM_EDS_FB_Send)
                {
                    Caption = 'Send';
                    ToolTip = 'Send the pre-configured documents to the business partner for all selected entries.';
                    Image = Email;
                    ApplicationArea = All;
                    Ellipsis = true;
                    Visible = GlobalAtLeastOneOutputTypeExistsBoolean;

                    trigger OnAction()
                    var
                        LocalRecordSalesInvoiceHeader: Record "Sales Invoice Header";
                        LocalCodeunitSIMEDSQueueMgt: Codeunit "SIM_EDS Queue Mgt";
                        LocalRecordRef: RecordRef;
                    begin
                        CurrPage.SetSelectionFilter(LocalRecordSalesInvoiceHeader);
                        if LocalRecordSalesInvoiceHeader.FindSet() then
                            repeat
                                LocalRecordRef.GetTable(LocalRecordSalesInvoiceHeader);
                                LocalCodeunitSIMEDSQueueMgt.SendEDS(LocalRecordRef, true, false, '');
                                LocalRecordRef.Close();
                            until LocalRecordSalesInvoiceHeader.Next() = 0;
                        CurrPage.SIM_EDSFB.Page.SetVariant(Rec);
                    end;
                }
                action(SIM_EDS_FB_SendDialog)
                {
                    Caption = 'Send Dialog';
                    ToolTip = 'Edit or personalize the email before sending it to the business partner.';
                    Image = Email;
                    ApplicationArea = All;
                    Ellipsis = true;
                    Visible = GlobalAtLeastOneOutputTypeExistsBoolean and GlobalSingleEntrySelectedBoolean;

                    trigger OnAction()
                    begin
                        CurrPage.SIM_EDSFB.Page.SendDialog();
                    end;
                }
                action(SIM_EDS_FB_DownloadAction)
                {
                    Caption = 'Download';
                    ToolTip = 'Download the pre-configured documents to the Document Dispatch business partner with the output type "Download" for all selected entries.';
                    Image = Download;
                    ApplicationArea = All;
                    Ellipsis = true;
                    Visible = GlobalSelectedContainsDownloadBoolean;

                    trigger OnAction()
                    var
                        LocalRecordSalesInvoiceHeader: Record "Sales Invoice Header";
                        LocalCodeunitSIMEDSMgt: Codeunit "SIM_EDS Mgt";
                        LocalTargetRecordRef: RecordRef;
                    begin
                        CurrPage.SetSelectionFilter(LocalRecordSalesInvoiceHeader);
                        LocalTargetRecordRef.GetTable(LocalRecordSalesInvoiceHeader);
                        LocalCodeunitSIMEDSMgt.DownloadDPForPageExtension(LocalTargetRecordRef, 'Posted Sales Invoice');
                        LocalTargetRecordRef.Close();
                    end;
                }
                action(SIM_EDS_FB_Schedule)
                {
                    Caption = 'Schedule';
                    ToolTip = 'Open the settings for scheduled dispatch for all selected entries.';
                    Image = ChangeDate;
                    ApplicationArea = All;
                    Ellipsis = true;
                    Visible = GlobalSingleEntrySelectedBoolean;

                    trigger OnAction()
                    begin
                        CurrPage.SIM_EDSFB.Page.ScheduleWizard();
                    end;
                }
                action(SIM_EDS_FB_Cancel)
                {
                    Caption = 'Cancel';
                    ToolTip = 'Cancel the dispatch for all selected entries. If the dispatch is scheduled or delayed and not yet executed, cancel the dispatch.';
                    Image = Cancel;
                    ApplicationArea = All;
                    Visible = GlobalCancelVisibleBoolean;

                    trigger OnAction()
                    begin
                        CurrPage.SIM_EDSFB.Page.Cancel();
                    end;
                }
                action(SIM_EDS_FB_Multimail)
                {
                    Caption = 'Multimail';
                    ToolTip = 'Send all marked entries via email.';
                    Ellipsis = true;
                    Image = SendTo;
                    ApplicationArea = All;
                    Visible = GlobalAtLeastOneOutputTypeExistsBoolean and not GlobalSingleEntrySelectedBoolean;

                    trigger OnAction()
                    begin
                        CurrPage.SIM_EDSFB.Page.Multimail();
                    end;
                }
                action(SIM_EDS_FB_OneDrive)
                {
                    Caption = 'Share through OneDrive';
                    ToolTip = 'Share the selected record through a OneDrive link.';
                    Ellipsis = true;
                    Image = Share;
                    Visible = GlobalSelectedContainsDownloadBoolean;
                    ApplicationArea = All;

                    trigger OnAction()
                    begin
                        CurrPage.SIM_EDSFB.Page.OneDriveShare('Posted Sales Invoice');
                    end;
                }
                action(SIM_EDS_FB_SetupBP)
                {
                    ApplicationArea = All;
                    Caption = 'Set up Business Partner';
                    ToolTip = 'Open the wizard to set up this Document Dispatch business partner for electronic dispatch, if not yet activated.';
                    Image = SalesPerson;
                    Visible = GlobalBusinessPartnerSetupVisibleBoolean and GlobalSingleEntrySelectedBoolean;
                    Ellipsis = true;

                    trigger OnAction()
                    begin
                        CurrPage.SIM_EDSFB.Page.SetupBusinessPartner();
                    end;
                }
                action(SIM_EDS_FB_ConfigureBP)
                {
                    ApplicationArea = All;
                    Caption = 'View/Configure Business Partner';
                    Image = EditCustomer;
                    Visible = GlobalIsBPConfigurationActiveBoolean and GlobalSingleEntrySelectedBoolean;
                    ToolTip = 'Open the Document Dispatch business partner setup page if a setup exists.';

                    trigger OnAction()
                    begin
                        CurrPage.SIM_EDSFB.Page.ConfigureBusinessPartner();
                    end;
                }
            }
        }
    }

    trigger OnOpenPage()
    begin
        GlobalIsUserRegisteredBoolean := CurrPage.SIM_EDSFB.Page.IsUserRegistered();
    end;

    trigger OnAfterGetCurrRecord()
    var
        LocalRecordSIMEDSSetup: Record "SIM_EDS Setup";
        LocalRecordSalesInvoiceHeader: Record "Sales Invoice Header";
        LocalCodeunitSIMCOREMgt: Codeunit "SIM_CORE Mgt";
        LocalRecordRef: RecordRef;
    begin
        if not LocalCodeunitSIMCOREMgt.CheckPermissions(UserSecurityId(), 'SIM_EDS USER | SIM_EDS ADMIN | SUPER') then exit;
        if not LocalRecordSIMEDSSetup.Get() then exit;

        CurrPage.SetSelectionFilter(LocalRecordSalesInvoiceHeader);
        LocalRecordRef.GetTable(LocalRecordSalesInvoiceHeader);
        CurrPage.SIM_EDSFB.Page.ProcessSelection(LocalRecordRef, Rec);

        GlobalSingleEntrySelectedBoolean := CurrPage.SIM_EDSFB.Page.IsSingleEntrySelected();
        GlobalAtLeastOneOutputTypeExistsBoolean := CurrPage.SIM_EDSFB.Page.GetAtLeastOneOutputTypeExists();
        GlobalSelectedContainsDownloadBoolean := CurrPage.SIM_EDSFB.Page.GetSelectedContainsDownloadBoolean();
        GlobalCancelVisibleBoolean := CurrPage.SIM_EDSFB.Page.IsCancelVisible();
        GlobalBusinessPartnerSetupVisibleBoolean := CurrPage.SIM_EDSFB.Page.IsBusinessPartnerSetupVisible();
        GlobalIsBPConfigurationActiveBoolean := CurrPage.SIM_EDSFB.Page.IsBPConfigurationActive();
    end;

    var
        GlobalIsUserRegisteredBoolean: Boolean;
        GlobalCancelVisibleBoolean: Boolean;
        GlobalBusinessPartnerSetupVisibleBoolean: Boolean;
        GlobalIsBPConfigurationActiveBoolean: Boolean;
        GlobalSingleEntrySelectedBoolean: Boolean;
        GlobalAtLeastOneOutputTypeExistsBoolean: Boolean;
        GlobalSelectedContainsDownloadBoolean: Boolean;
}
- For Document Dispatch from BC25 and above
pageextension 5487166 "SIM_EDS PostedSalesInvoicesExt" extends "Posted Sales Invoices" //143
{
    layout
    {
        addfirst(FactBoxes)
        {
            part(SIM_EDSFB; "SIM_EDS FB")
            {
                ApplicationArea = All;
            }
        }
    }
    actions
    {
        addafter(Category_Category5)
        {
            group(SIM_EDS_Actions_Promoted)
            {
                Caption = 'Document Dispatch';
                ShowAs = Standard;
                Image = SendTo;
                Visible = GlobalIsUserRegisteredBoolean;

                actionref(SIM_EDS_FB_Send_Promoted; SIM_EDS_FB_Send) { }
                actionref(SIM_EDS_FB_SendDialog_Promoted; SIM_EDS_FB_SendDialog) { }
                actionref(SIM_EDS_FB_DownloadAction_Promoted; SIM_EDS_FB_DownloadAction) { }
                actionref(SIM_EDS_FB_Schedule_Promoted; SIM_EDS_FB_Schedule) { }
                actionref(SIM_EDS_FB_Cancel_Promoted; SIM_EDS_FB_Cancel) { }
                actionref(SIM_EDS_FB_Multimail_Promoted; SIM_EDS_FB_Multimail) { }
                actionref(SIM_EDS_FB_OneDrive_Promoted; SIM_EDS_FB_OneDrive) { }
                actionref(SIM_EDS_FB_AddToPrintList_Promoted; SIM_EDS_FB_AddToPrintList) { }
                actionref(SIM_EDS_FB_SetupBP_Promoted; SIM_EDS_FB_SetupBP) { }
                actionref(SIM_EDS_FB_ConfigureBP_Promoted; SIM_EDS_FB_ConfigureBP) { }
            }
        }
        addlast(processing)
        {
            group(SIM_EDS_FB_Actions)
            {
                Caption = 'Document Dispatch';
                Visible = GlobalIsUserRegisteredBoolean;

                action(SIM_EDS_FB_Send)
                {
                    Caption = 'Send';
                    ToolTip = 'Send the pre-configured documents to the business partner for all selected entries.';
                    Image = Email;
                    ApplicationArea = All;
                    Ellipsis = true;
                    Visible = GlobalAtLeastOneOutputTypeExistsBoolean or GlobalSelectedContainsEPostBoolean;

                    trigger OnAction()
                    var
                        LocalRecordSalesInvoiceHeader: Record "Sales Invoice Header";
                        LocalCodeunitSIMEDSQueueMgt: Codeunit "SIM_EDS Queue Mgt";
                        LocalRecordRef: RecordRef;
                    begin
                        CurrPage.SetSelectionFilter(LocalRecordSalesInvoiceHeader);
                        if LocalRecordSalesInvoiceHeader.FindSet() then
                            repeat
                                LocalRecordRef.GetTable(LocalRecordSalesInvoiceHeader);
                                LocalCodeunitSIMEDSQueueMgt.SendEDS(LocalRecordRef, true, false, '');
                                LocalRecordRef.Close();
                            until LocalRecordSalesInvoiceHeader.Next() = 0;
                        CurrPage.SIM_EDSFB.Page.SetVariant(Rec);
                    end;
                }
                action(SIM_EDS_FB_SendDialog)
                {
                    Caption = 'Send Dialog';
                    ToolTip = 'Edit or personalize the email before sending it to the business partner.';
                    Image = Email;
                    ApplicationArea = All;
                    Ellipsis = true;
                    Visible = (GlobalAtLeastOneOutputTypeExistsBoolean or GlobalSelectedContainsEPostBoolean) and GlobalSingleEntrySelectedBoolean;

                    trigger OnAction()
                    begin
                        CurrPage.SIM_EDSFB.Page.SendDialog();
                    end;
                }
                action(SIM_EDS_FB_DownloadAction)
                {
                    Caption = 'Download';
                    ToolTip = 'Download the pre-configured documents to the Document Dispatch business partner with the output type "Download" for all selected entries.';
                    Image = Download;
                    ApplicationArea = All;
                    Ellipsis = true;
                    Visible = GlobalSelectedContainsDownloadBoolean;

                    trigger OnAction()
                    var
                        LocalRecordSalesInvoiceHeader: Record "Sales Invoice Header";
                        LocalCodeunitSIMEDSMgt: Codeunit "SIM_EDS Mgt";
                        LocalTargetRecordRef: RecordRef;
                    begin
                        CurrPage.SetSelectionFilter(LocalRecordSalesInvoiceHeader);
                        LocalTargetRecordRef.GetTable(LocalRecordSalesInvoiceHeader);
                        LocalCodeunitSIMEDSMgt.DownloadDPForPageExtension(LocalTargetRecordRef, 'Posted Sales Invoice');
                        LocalTargetRecordRef.Close();
                    end;
                }
                action(SIM_EDS_FB_Schedule)
                {
                    Caption = 'Schedule';
                    ToolTip = 'Open the settings for scheduled dispatch for all selected entries.';
                    Image = ChangeDate;
                    ApplicationArea = All;
                    Ellipsis = true;
                    Visible = GlobalSingleEntrySelectedBoolean;

                    trigger OnAction()
                    begin
                        CurrPage.SIM_EDSFB.Page.ScheduleWizard();
                    end;
                }
                action(SIM_EDS_FB_Cancel)
                {
                    Caption = 'Cancel';
                    ToolTip = 'Cancel the dispatch for all selected entries. If the dispatch is scheduled or delayed and not yet executed, cancel the dispatch.';
                    Image = Cancel;
                    ApplicationArea = All;
                    Visible = GlobalCancelVisibleBoolean;

                    trigger OnAction()
                    begin
                        CurrPage.SIM_EDSFB.Page.Cancel();
                    end;
                }
                action(SIM_EDS_FB_Multimail)
                {
                    Caption = 'Multimail';
                    ToolTip = 'Send all marked entries via email.';
                    Ellipsis = true;
                    Image = SendTo;
                    ApplicationArea = All;
                    Visible = GlobalAtLeastOneOutputTypeExistsBoolean and not GlobalSingleEntrySelectedBoolean;

                    trigger OnAction()
                    begin
                        CurrPage.SIM_EDSFB.Page.Multimail();
                    end;
                }
                action(SIM_EDS_FB_OneDrive)
                {
                    Caption = 'Share through OneDrive';
                    ToolTip = 'Share the selected record through a OneDrive link.';
                    Ellipsis = true;
                    Image = Share;
                    Visible = GlobalSelectedContainsDownloadBoolean;
                    ApplicationArea = All;

                    trigger OnAction()
                    begin
                        CurrPage.SIM_EDSFB.Page.OneDriveShare('Posted Sales Invoice');
                    end;
                }
                action(SIM_EDS_FB_SetupBP)
                {
                    ApplicationArea = All;
                    Caption = 'Set up Business Partner';
                    ToolTip = 'Open the wizard to set up this Document Dispatch business partner for electronic dispatch, if not yet activated.';
                    Image = SalesPerson;
                    Visible = GlobalBusinessPartnerSetupVisibleBoolean and GlobalSingleEntrySelectedBoolean;
                    Ellipsis = true;

                    trigger OnAction()
                    begin
                        CurrPage.SIM_EDSFB.Page.SetupBusinessPartner();
                    end;
                }
                action(SIM_EDS_FB_ConfigureBP)
                {
                    ApplicationArea = All;
                    Caption = 'View/Configure Business Partner';
                    Image = EditCustomer;
                    Visible = GlobalIsBPConfigurationActiveBoolean and GlobalSingleEntrySelectedBoolean;
                    ToolTip = 'Open the Document Dispatch business partner setup page if a setup exists.';

                    trigger OnAction()
                    begin
                        CurrPage.SIM_EDSFB.Page.ConfigureBusinessPartner();
                    end;
                }
                action(SIM_EDS_FB_AddToPrintList)
                {
                    Caption = 'Add to Print List';
                    ToolTip = 'Add the selected entries to the print list.';
                    Image = PrintCheck;
                    ApplicationArea = All;
                    Visible = GlobalSelectedContainsPrintListBoolean;

                    trigger OnAction()
                    begin
                        CurrPage.SIM_EDSFB.Page.AddToPrintList();
                    end;
                }
            }
        }
    }

    trigger OnOpenPage()
    begin
        GlobalIsUserRegisteredBoolean := CurrPage.SIM_EDSFB.Page.IsUserRegistered();
    end;

    trigger OnAfterGetCurrRecord()
    var
        LocalRecordSIMEDSSetup: Record "SIM_EDS Setup";
        LocalRecordSalesInvoiceHeader: Record "Sales Invoice Header";
        LocalCodeunitSIMCOREMgt: Codeunit "SIM_CORE Mgt";
        LocalRecordRef: RecordRef;
    begin
        if not LocalCodeunitSIMCOREMgt.CheckPermissions(UserSecurityId(), 'SIM_EDS USER | SIM_EDS ADMIN | SUPER') then exit;
        if not LocalRecordSIMEDSSetup.Get() then exit;

        CurrPage.SetSelectionFilter(LocalRecordSalesInvoiceHeader);
        LocalRecordRef.GetTable(LocalRecordSalesInvoiceHeader);
        CurrPage.SIM_EDSFB.Page.ProcessSelection(LocalRecordRef, Rec);

        GlobalSingleEntrySelectedBoolean := CurrPage.SIM_EDSFB.Page.IsSingleEntrySelected();
        GlobalAtLeastOneOutputTypeExistsBoolean := CurrPage.SIM_EDSFB.Page.GetAtLeastOneOutputTypeExists();
        GlobalSelectedContainsDownloadBoolean := CurrPage.SIM_EDSFB.Page.GetSelectedContainsDownloadBoolean();
        GlobalSelectedContainsEPostBoolean := CurrPage.SIM_EDSFB.Page.GetSelectedContainsEPostBoolean();
        GlobalSelectedContainsPrintListBoolean := CurrPage.SIM_EDSFB.Page.GetSelectedContainsPrintListBoolean();
        GlobalCancelVisibleBoolean := CurrPage.SIM_EDSFB.Page.IsCancelVisible();
        GlobalBusinessPartnerSetupVisibleBoolean := CurrPage.SIM_EDSFB.Page.IsBusinessPartnerSetupVisible();
        GlobalIsBPConfigurationActiveBoolean := CurrPage.SIM_EDSFB.Page.IsBPConfigurationActive();
    end;

    var
        GlobalIsUserRegisteredBoolean: Boolean;
        GlobalCancelVisibleBoolean: Boolean;
        GlobalBusinessPartnerSetupVisibleBoolean: Boolean;
        GlobalIsBPConfigurationActiveBoolean: Boolean;
        GlobalSingleEntrySelectedBoolean: Boolean;
        GlobalAtLeastOneOutputTypeExistsBoolean: Boolean;
        GlobalSelectedContainsDownloadBoolean: Boolean;
        GlobalSelectedContainsEPostBoolean: Boolean;
        GlobalSelectedContainsPrintListBoolean: Boolean;
}

Info

The Document Dispatch Factbox enables documents to be sent for the desired entries. It ensures that documents are sent to the correct recipients based on the configured dispatch logic.