The SharePoint connector comes with the SharePoint factbox installed on many pages, but maybe you want the factbox somewhere else?

Not a problem, you can create an extension that takes dependency to the SharePoint Connector and add the fact box to all the pages you need. (Or your partner can if you give them a link to this page).

First add the dependency to your app.json like this:

{
  "id": "23ebd065-b289-4a68-85e3-b8410e360157",
  "name": "SharePoint Connector",
  "publisher": "EFOQUS Canada Inc.",
  "version": "2.0.0.10"
}

Then add one or more pages xtension objects to cover the places you need the factbox. Use the below snippet as a template. The only thing you need to do is editing the first line with:

  • Give it an object number
  • Give it a name
  • Replace the “Page Name” with the name of the page
pageextension <Object Number> <Object Name> extends <Page Name>
{
  layout
  {
      addfirst(factboxes)
      {
          part(SharePointPart_EFQ; "SharePoint Factbox EFQ")
          {
              ApplicationArea = All;
              Visible = SharePointActivated;
          }
      }
  }
  trigger OnAfterGetCurrRecord()
  var
      Mapping: Record "Table Mapping EFQ";
      SP: Codeunit "SharePoint EFQ";
      Ref: RecordRef;
      Parms: Dictionary of [Text, Text];
      PageTaskId: Integer;
  begin
      if SharePointActivated then
          if GuiAllowed then begin
              Ref.GetTable(Rec);
              SP.GetTableMapping(Mapping, Ref);
              CLEAR(Parms);
              Parms.Add('sitename', Mapping."Site Name");
              Parms.Add('basefolder', Mapping."Base Folder");
              Parms.Add('folder', CurrPage.SharePointPart_EFQ.Page.PrepareFill(Ref));
              CurrPage.EnqueueBackgroundTask(PageTaskId, Codeunit::"Factbox Background Task EFQ", Parms, 30000, PageBackgroundTaskErrorLevel::Warning);
          end;
  end;
  trigger OnPageBackgroundTaskCompleted(TaskId: Integer; Results: Dictionary of [Text, Text])
  begin
      if SharePointActivated then
          CurrPage.SharePointPart_EFQ.Page.FinishFill(Results);
  end;
  trigger OnPageBackgroundTaskError(TaskId: Integer; ErrorCode: Text; ErrorText: Text; ErrorCallStack: Text; var IsHandled: Boolean)
  begin
      if SharePointActivated then
          CurrPage.SharePointPart_EFQ.Page.FillError(ErrorText);
  end;
  trigger OnOpenPage()
  var
      TableMapping: Record "Table Mapping EFQ";
      Ref: RecordRef;
  begin
      Ref.GetTable(Rec);
      SharePointActivated := TableMapping.NeedsFactBox(Ref.Number());
  end;
  var
      SharePointActivated: Boolean;
}

That’s it, now you have added the SharePoint connector to the page and connected it to the data (Rec).