<< Click to Display Table of Contents >> Navigation: Zetadocs SDK Guide > Creating a Per Tenant Extension > Adding Zetadocs to a Business Central Page |
This chapter demonstrates how to add the Zetadocs Delivery Send Actions and Zetadocs Capture Factbox to a Business Central Page. The examples in this document are for Sales Quotes and can be extended or modified to suit your needs.
Adding the Zetadocs FactBox to a page
You will have to create a Per Tenant Extension with a Page Extension to add the Zetadocs Factbox to an existing page.
The factbox can be added to the following page types:
The code example below shows how to add the Zetadocs factbox to a page:
layout
{
addfirst(FactBoxes)
{
part(ZddWebClient; "Zetadocs Web Rel. Docs. Page")
{
ApplicationArea = All;
Visible = ZddIsFactboxVisible;
}
}
}
var
ZddPrevRecID: RecordID;
ZddIsFactboxVisible: Boolean;
ZddIsActionsVisible: Boolean;
ZddIsOnAfterGetCurrRecordInitialised: Boolean;
trigger OnAfterGetCurrRecord()
var
ZdCommon: Codeunit "Zetadocs Common";
ZdRecRef: RecordRef;
begin
if not ZddIsOnAfterGetCurrRecordInitialised then begin
// Inside OnAfterGetCurrRecord to work around BC sometimes not triggering it
ZddIsOnAfterGetCurrRecordInitialised := true;
ZddIsFactboxVisible := ZdCommon.IsFactboxVisibleForPage(CurrPage.OBJECTID(FALSE));
end;
if GuiAllowed then begin
ZdRecRef.GetTable(Rec);
if ZdRecRef.Get(ZdRecRef.RecordId) and (ZdRecRef.RecordId <> ZddPrevRecID) then begin
ZddPrevRecID := ZdRecRef.RecordId;
CurrPage.ZddWebClient.PAGE.SetRecordID(ZdRecRef.RecordId);
CurrPage.ZddWebClient.PAGE.Update(false);
end;
end;
end;
Adding the Zetadocs Send Actions Items to a page
In Zetadocs Delivery, there are three action items added to the menu of a Business Central Page. The Zetadocs “Actions” are Send, Outbox, and Rules. These menu items are added to the Processing menu, under actions, and then under the group “Zetadocs”.
The actions Outbox and Rules have a RunObject parameter to open a Page when clicked. The Send action has a trigger to run code when clicked.
The trigger for OnAction has specific report selection to the page in question. Please keep in mind this line of code will need to be modified to match the report to send.
Adding the Zetadocs Send and Capture as an extension
pageextension 9041214 "Zdd Sales Quote" extends "Sales Quote"
{
layout
{
addfirst(FactBoxes)
{
part(ZddWebClient; "Zetadocs Web Rel. Docs. Page")
{
ApplicationArea = All;
Visible = ZddIsFactboxVisible;
}
}
}
actions
{
addfirst(Processing)
{
group(Zetadocs)
{
Caption = 'Zetadocs';
Visible = ZddIsActionsVisible;
action(ZddSend)
{
Caption = 'Send';
Image = SendMail;
ToolTip = 'Send via Zetadocs';
ApplicationArea = All;
trigger OnAction()
var
ZdReportSelections: Record "Report Selections";
ZdServerSend: Codeunit "Zetadocs Server Send";
ZdCommon: Codeunit "Zetadocs Common";
ZdRecRef: RecordRef;
ZdReportId: Integer;
begin
ZdRecRef.GetTable(Rec);
ZdCommon.FindSelectionReportId(ZdReportSelections.Usage::"S.Quote", ZdReportId);
ZdServerSend.SendViaZetadocs(ZdRecRef, ZdReportId, '', true);
end;
}
action(ZddOutbox)
{
Caption = 'Outbox';
Image = OverdueMail;
RunObject = Page "Zetadocs Delivery Outbox";
ToolTip = 'Open the Zetadocs Delivery Outbox';
ApplicationArea = All;
}
action(ZddRules)
{
Caption = 'Rules';
Image = CheckRulesSyntax;
RunObject = Page "Zetadocs Customer Rule List";
ToolTip = 'Open the Rules';
ApplicationArea = All;
}
}
}
}
var
ZddPrevRecID: RecordID;
ZddIsFactboxVisible: Boolean;
ZddIsActionsVisible: Boolean;
ZddIsOnAfterGetCurrRecordInitialised: Boolean;
trigger OnOpenPage()
var
ZdCommon: Codeunit "Zetadocs Common";
begin
ZddIsActionsVisible := ZdCommon.IsActionsVisibleForPage(CurrPage.OBJECTID(FALSE));
end;
trigger OnAfterGetCurrRecord()
var
ZdCommon: Codeunit "Zetadocs Common";
ZdRecRef: RecordRef;
begin
if not ZddIsOnAfterGetCurrRecordInitialised then begin
// Inside OnAfterGetCurrRecord to work around BC sometimes not triggering it
ZddIsOnAfterGetCurrRecordInitialised := true;
ZddIsFactboxVisible := ZdCommon.IsFactboxVisibleForPage(CurrPage.OBJECTID(FALSE));
end;
if (GuiAllowed and ZddIsFactboxVisible) then begin
ZdRecRef.GetTable(Rec);
if ZdRecRef.Get(ZdRecRef.RecordId) and (ZdRecRef.RecordId <> ZddPrevRecID) then begin
ZddPrevRecID := ZdRecRef.RecordId;
CurrPage.ZddWebClient.PAGE.SetRecordID(ZdRecRef.RecordId);
CurrPage.ZddWebClient.PAGE.Update(false);
end;
end;
end;
}
Report Link Setup
A step needs to be taken to configure the report printing correctly, this can be done in the Zetadocs Report Settings page, a new record should be created for the Report Id defined in ZdReportSelections.Usage::"SM.Order" , for example Service Order is report 5900, select a Document Set to apply to this report, then finally setup the Report Mappings, this consists of selecting the appropriate table and filter to apply. More details on the Report Settings page can be found here.
Display the Zetadocs Factbox only for licensed users
By default, the Zetadocs Factbox will be displayed to all users. It can he hidden for specific users using the Business Central page personalizations.
If you want a more general approach, you can serve the Zetadocs Factbox to only Zetadocs licensed users. By doing so, the Factbox will only be visible if the current user is a Zetadocs Delivery Express or higher, or a Zetadocs Capture Express or higher.
To enable this behavior, navigate to the Zetadocs System Settings page. Add the entry 'ShowFactboxOnlyToLicensedUsers' and set the boolean column to true (tick the box).