<< Click to Display Table of Contents >> Navigation: Zetadocs SDK Guide > Creating a Per Tenant Extension |
Microsoft have a very good walkthrough that a lot of this document will be referencing, and is certainly worth reading as a pre-requisite, it’s found here.
Extension Dependency for Zetadocs
A dependency on the Zetadocs Capture and Zetadocs Delivery Extension needs to be added to the App.json of the Per Tenant Extension, the following is a code snippet to do this, note the version should match the version of Zetadocs installed (this can be found by searching BC for Extensions):
"dependencies": [
{
"appId": "069f3d48-1c17-459e-bbc6-3f00693bb507",
"publisher": "Equisys",
"name": "Zetadocs Delivery and Zetadocs Capture",
"version": "1.0.20185.15"
}
]
Once the dependency has been added, make sure to Download Symbols (in VS Code this is Ctrl+Shift+P and type AL: Download Symbols)
Events
The idea is that you can run customized code at certain points in the software using events, they’re based off the .net framework so should be quite familiar, they comprise of three parts:
Subscribe to an event
[EventSubscriber(ObjectType::<Event Publisher Object Type>, <Event Publisher Object>, '<Published Event Name>', '<Published Event Element Name>', <SkipOnMissingLicense>, <SkipOnMissingPermission>)]
<Event Publisher Object Type> this is the type of object that’s publishing the event, so Codeunit, Page, Table. For example, Codeunit
<Event Publisher Object> the object that publishes the object, you can use the id or the name, so for example Codeunit::” MyPublishers”
<Published Event Name> the name of the publisher method, in our example this is, OnAddressLineChanged.
The rest of the values are less important and can usually be left to default values ‘’, false, false. Look up the MSDN documentation for more information if you need it here.
In the example Subscriber below note how the method parameter matches the parameter from the Publisher event.
codeunit 70000002 MySubscriber
{
EventSubscriberInstance = StaticAutomatic;
[EventSubscriber(ObjectType::Codeunit, Codeunit::"MyPublishers", 'OnAddressLineChanged', '', true, true)]
procedure CheckAddressLine(line : Text[100]);
begin
if (STRPOS(line, '+') > 0) then begin
MESSAGE('Cannot use a plus sign (+) in the address [' + line + ']');
end;
end;
}
Examples of our Events can be found in the Zetadocs Customize codeunit.
Creating a BC Extension
To create a more in depth BC extension, with new tables, pages, and codeunits, you should be able to follow the Microsoft example, I will just outline a way of producing a very simple Per Tenant Extension.
page 50110 PageName
{
PageType = Card;
actions
{
// Adds the action called "My Actions" to the Action menu
area(Processing)
{
action("My Actions")
{
Promoted = true;
PromotedCategory = Process;
ApplicationArea = All;
trigger OnAction()
begin
Message('Hello World');
end;
}
}
area(Creation)
{
// Adds the action "My New document" to the New Document group in the Actions menu.
action("My New document")
{
ApplicationArea = All;
RunObject = page "Customer Card";
Image = "1099Form";
}
}
area(Navigation)
{
// Adds the action called "My Navigate" to the Navigate menu.
action("My Navigate")
{
ApplicationArea = All;
RunObject = page "Customer Card";
}
}
area(Reporting)
{
// Adds a submenu called "My Label" to the Report menu.
group(NewSubGroup)
{
Caption = 'My label';
group(MyGroup)
{
// Adds the action "My Report" to the My Label submenu.
action("My Report")
{
ApplicationArea = All;
RunObject = page "Customer Card";
}
}
}
}
}
}