Skip to content

Files FactBox

The Bridge library app adds a file factbox that can be used for uploading and downloading files to/from the Document Archive remote file storage.

FactBox on Item Card Page

The functionality of the file factbox only works after installing the Document Archive extension which implements the logic for uploading, downloading, deleting and retrieving files.

For more information about the features and capabilities of the file factbox, please see the Files FactBox section of the Document Archive online user manual.

Adding the FactBox to Other Pages

To add the file factbox yourself to other pages, please follow these steps:

  1. First, add a dependency to the Bridge library app to the app.json manifest file of your Business Central extension:

    app.json
    {
      "id": "your-extension-id",
      "name": "Your Extension Name",
      "publisher": "Publisher Name",
      "version": "1.0.0.0",
    
      // other properties
    
      "dependencies": [
        {
          "id": "b5ce5789-b419-4fd4-80d3-abddadf4995f",
          "name": "Bridge",
          "publisher": "Apportunix",
          "version": "1.0.0.0"
        }
      ]
    }
    
  2. Then, on the page or pageextension object to which you would like to add the file factbox, add the factboxes as follows with the appropriate trigger implementations:

    AL: Sample of adding the Files factbox using a pageextension object
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    pageextension 50100 AssemblyOrderExt extends "Assembly Order"
    {
        layout
        {
            addfirst(Factboxes)
            {
                part(BRGFileFactBox; WSB_BRGFileFactBox)
                {
                    ApplicationArea = All;
                    Enabled = FileFactBoxVisible;
                    Visible = FileFactBoxVisible;
                }
                part(BRGFileCategoryFactBox; WSB_BRGFileCategoryFactBox)
                {
                    ApplicationArea = All;
                    Enabled = FileCategoryFactBoxVisible;
                    Visible = FileCategoryFactBoxVisible;
                }
            }
        }
    
        var
            FileFactBoxVisible, FileCategoryFactBoxVisible: Boolean;
    
        trigger OnOpenPage()
        begin
            FileFactBoxVisible := CurrPage.BRGFileFactBox.Page.wgFncShowFactBox();
            FileCategoryFactBoxVisible := CurrPage.BRGFileCategoryFactBox.Page.wgFncShowFactBox();
        end;
    
        trigger OnAfterGetCurrRecord()
        begin
            CurrPage.BRGFileFactBox.Page.wgFncSetRecordId(Rec.RecordId());
            CurrPage.BRGFileCategoryFactBox.Page.wgFncSetRecordId(Rec.RecordId());
        end;
    }
    
  3. Finally, implement an event subscriber for the following event publisher:

    WSB_BRGFileFactBoxPublishers.wgEvpOnGetPrimaryValues

    Allows you to specify the primary key field values given a RecordRef of the source table record that the file should be linked to.

    AL: Sample event subscriber implementation
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    [EventSubscriber(ObjectType::Codeunit, Codeunit::WSB_BRGFileFactBoxPublishers, wgEvpOnGetPrimaryValues, '', true, true)]
    local procedure OnGetPrimaryValuesEventSubscriber(pRecRef: RecordRef; var vSourceType: Integer; var vSourceNo: Code[20]; var vIsHandled: Boolean)
    var
        AssemblyHdr: Record "Assembly Header";
    begin
        if vIsHandled then
            exit;
    
        if pRecRef.Number <> Database::"Assembly Header" then
            exit;
    
        pRecRef.SetTable(AssemblyHdr);
        vSourceType := AssemblyHdr."Document Type".AsInteger();
        vSourceNo := AssemblyHdr."No.";
    
        vIsHandled := true;
    end;
    

Last update: December 20, 2023