<< Click to Display Table of Contents >> Navigation: Zetadocs SDK Guide > Creating a Per Tenant Extension > Delivery Automation |
Programmatically send Released Sales Orders Example
The following example illustrates how to use the Zetadocs Server Send codeunit to programmatically send via Zetadocs. The logic will require a Per Tenant Extension.
codeunit 50680 "Zetadocs PTE Capture Customize"
{
trigger OnRun()
begin
SendReleasedSalesOrders();
end;
procedure SendReleasedSalesOrders()
var
ZdServerSend: Codeunit "Zetadocs Server Send";
FilterTemp: Text;
requestPageParameters: Text;
begin
//The following example will send all the Sales Orders which are released and waiting for posting.
//Initialize the Filter.
FilterTemp := 'Status=FILTER(Released)';
//Filter consolidation in case the filter was not set.
IF FilterTemp = '' THEN BEGIN
//If the filter is empty, get all the items
FilterTemp := 'No.=FILTER(*)';
END;
//Create the parameters needed for the Order Confirmation.
//Please consult REPORT.RUNREQUESTPAGE from the Business Central help for more information.
requestPageParameters := '<?xml version="1.0" standalone="yes"?>'
+ '<ReportParameters name="Standard Sales - Order Conf." id="1305">'
+ '<Options>'
+ '<Field name="LogInteraction">true</Field>'
+ '<Field name="DisplayAssemblyInformation">false</Field>'
+ '<Field name="ArchiveDocument">false</Field>'
+ '</Options>'
+ '<DataItems>'
+ '<DataItem name="Header">VERSION(1) SORTING(Field1,Field3) WHERE(' + FilterTemp + ')</DataItem>'
+ '<DataItem name="Line">VERSION(1) SORTING(Field3,Field4)</DataItem>'
+ '<DataItem name="AssemblyLine">VERSION(1) SORTING(Field2,Field3)</DataItem>'
+ '<DataItem name="WorkDescriptionLines">VERSION(1) SORTING(Field1)</DataItem>'
+ '<DataItem name="VATAmountLine">VERSION(1) SORTING(Field5,Field9,Field10,Field13,Field16)</DataItem>'
+ '<DataItem name="VATClauseLine">VERSION(1) SORTING(Field5,Field9,Field10,Field13,Field16)</DataItem>'
+ '<DataItem name="ReportTotalsLine">VERSION(1) SORTING(Field1)</DataItem>'
+ '<DataItem name="LetterText">VERSION(1) SORTING(Field1)</DataItem>'
+ '<DataItem name="Totals">VERSION(1) SORTING(Field1)</DataItem>'
+ '</DataItems>'
+ '</ReportParameters>';
//Submit the batch, Zetadocs will process it in the background
ZdServerSend.SendViaZetadocs(1305, requestPageParameters, FALSE);
//Where SendViaZetadocs(ReportID : Integer;RequestPageParams : Text;ShowUI : Boolean)
//Please note that ShowUI must be FALSE for automation, and it only works if the RequestPageParam is not empty.
end;
}
Delivery Automation
Once the Per Tenant Extension is installed and tested, the Delivery process can be automated using a Job Queue entry.
To do so, you will need to: