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 sub-items that have been set up, such as availability or similar, and to send documents if they have been set up correctly.

There are two ways to do this:

  1. When using a custom page, the code can be added directly to the page.
  2. If wanted 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

pageextension 5487161 "SIM_EDS PostedSalesInvoiceExt" extends "Posted Sales Invoice" //132
{
    layout
    {
        addfirst(FactBoxes)
        {
            part(SIM_EDSFB; "SIM_EDS FB")
            {
                ApplicationArea = All;
            }
        }
    }
    trigger OnAfterGetCurrRecord()
    var
        LocalCodeunitSIMCOREMgt: Codeunit "SIM_CORE Mgt";
    begin
        if not LocalCodeunitSIMCOREMgt.CheckPermissions(UserSecurityId(), 'SIM_EDS USER | SIM_EDS ADMIN | SUPER') then exit;
        CurrPage.SIM_EDSFB.Page.SetVariant(Rec);
    end;
}

List

pageextension 5487166 "SIM_EDS PostedSalesInvoicesExt" extends "Posted Sales Invoices" //143
{
    layout
    {
        addfirst(FactBoxes)
        {
            part(SIM_EDSFB; "SIM_EDS FB")
            {
                ApplicationArea = All;
            }
        }
    }

    trigger OnAfterGetCurrRecord()
    var
        TempLocalRecordSIMEDSBusinessPartner: Record "SIM_EDS Business Partner" temporary;
        TempLocalRecordSIMEDSDynamicBP: Record "SIM_EDS Dynamic BP" temporary;
        LocalRecordSalesInvoiceHeader: Record "Sales Invoice Header";
        TempLocalRecordSIMEDSRecord: Record "SIM_EDS Record" temporary;
        LocalRecordSIMEDSSetup: Record "SIM_EDS Setup";
        LocalCodeunitSIMEDSMgt: Codeunit "SIM_EDS Mgt";
        LocalCodeunitSIMCOREMgt: Codeunit "SIM_CORE Mgt";
        LocalRecordRef: RecordRef;
        LocalDynamicBusinessMappingExistsBoolean: Boolean;
        LocalExtendedBusinessMappingExistsBoolean: Boolean;
        LocalMultipleOutputTypesExistsBoolean: Boolean;
    begin
        if not LocalCodeunitSIMCOREMgt.CheckPermissions(UserSecurityId(), 'SIM_EDS USER | SIM_EDS ADMIN | SUPER') then exit;
        CurrPage.SIM_EDSFB.Page.SetVariant(Rec);

        if not LocalRecordSIMEDSSetup.Get() then exit;

        CurrPage.SetSelectionFilter(LocalRecordSalesInvoiceHeader);

        if LocalRecordSalesInvoiceHeader.FindSet() then
            repeat
                LocalRecordRef.GetTable(LocalRecordSalesInvoiceHeader);
                LocalCodeunitSIMEDSMgt.GetRecords(LocalRecordRef, TempLocalRecordSIMEDSRecord);

                LocalCodeunitSIMEDSMgt.GetRecordAssignedData(
                    LocalRecordRef,
                    true,
                    LocalDynamicBusinessMappingExistsBoolean,
                    LocalExtendedBusinessMappingExistsBoolean,
                TempLocalRecordSIMEDSRecord,
                    TempLocalRecordSIMEDSBusinessPartner,
                    TempLocalRecordSIMEDSDynamicBP,
                    true);

                LocalCodeunitSIMEDSMgt.CheckOutputTypes(LocalRecordRef, TempLocalRecordSIMEDSRecord, GlobalIsDownloadEnabledBoolean, LocalMultipleOutputTypesExistsBoolean);
            until LocalRecordSalesInvoiceHeader.Next() = 0;
    end;

    var
        GlobalIsDownloadEnabledBoolean: 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.