Technical Notes, Zetadocs

HOWTO: Send any report with Zetadocs for Microsoft Dynamics NAV

ZTN4273

ID: ZTN4273

This Zetadocs technical note applies to:

  • Zetadocs for Microsoft Dynamics NAV

Summary

This technote details the steps required to enable a Zetadocs for NAV system to send any report.

More information

In the Zetadocs for NAV installation guide are details of how to configure Zetadocs for NAV to send reports from the Sales Order and Purchasing processes. It details how to edit the NAV reports for Zetadocs for NAV and set the report settings to point at the Customer or Vendor reference for that report and the respective Contact reference. With this information Zetadocs for NAV was able to extract the references and query the names, email addresses and fax addresses of the contact, as well as, cross reference the company (Customer or Vendor) reference with the associated Zetadocs Customer or Vendor rules tables to apply per company formatting and addressing logic. This however is not the limit of Zetadocs for NAV functionality. This principle of field reference and related information resolution can be applied to almost any report. In this section we will see how small changes in the report settings can control and alter the information used to address, format, send and archive a report using Zetadocs for NAV.

Configured Send

It should be clear by now from reviewing the installation guide that by setting the "Company Type Code", "Company No. Field No." and "Contact No. Field No." fields in the Zetadocs Report Settings that you can configure Zetadocs for NAV to automatically resolve your contact information and apply company specific rules if they exist. In this way it is possible to reference any fields which contain the right type of reference (i.e. customer/vendor or contact etc). There is some logic to the application of these settings that is important to know to help decide what settings to enter but it also gives the opportunity for some variations in configuration.

Zetadocs Report Settings Field No.'s Reference Logic (Pseudo Code)

IF Company Type Code < > NULL THEN

IF Company No. Field No. < > NULL THEN

  Get the Company No. from Record using Field No.

ELSE

  CALL Integration codeunit GetCompanyForReport for VAR to get Company No.

END

END

Send Result.VALIDATE(Company No., Company No. Value)

IF Contact No. Field No. < > NULL THEN

  Get the Contact No. from Record using Field No.

ELSE

  CALL Integration codeunit GetContactForReport for VAR to get Contact No.

END

Send Result.VALIDATE(Contact No., Contact No. Value)

From this it is important to notice the order that validation happens in as this coordinates with the Zetadocs Send Result table OnValidate trigger code for "Company No." and "Contact No.". Since the company information is validated first no contact reference will be set yet. We can check for this and default to using the company's communication information, later when the contact reference is validated we can override the addressing information (email, fax). This provides the fallback addressing logic of Zetadocs for NAV so that if a record has a blank reference for a contact we will still end up with the company correspondence information. This means that we can deliberately control what information is used by altering the settings. It also means that this behavior can be customized by the VAR by implementing the get trigger functions in the Zetadocs-Send Integration codeunit and/or changing the OnValidate triggers in the Zetadocs Send Result table.

Company Type Code

Company No. Field No.

Contact No. Field No.

Resulting Addressing Info Used

SET

SET

SET

Contact Info unless the reference in record is blank THEN Company Info

SET

NULL

SET

Contact Info unless the reference in record is blank THEN Company Info using Company Reference implemented by VAR

SET

NULL

NULL

Contact Info using Contact Reference Implemented by VAR unless that reference is blank THEN Company Info using Company Reference implemented by VAR

NULL

NULL

SET

Contact Info

NULL

SET

SET/NULL

Invalid - You must specify a company type to enable use of company field.

Custom Send

We saw in the last section how selecting certain report settings can control the flow of the operation of the Zetadocs processing codeunits. By exploiting these settings and implementing the trigger functions in the Zetadocs-Send Integration codeunit we can highly customize our report sending. In this section we will focus on the trigger functions in the Zetadocs-Send Integration codeunit and explain how they can be used.

GetZetadocsArchiveID

This function has been deprecated in version 5.0 of Zetadocs for NAV and remains in the code for backward compatibility. For system upgrades please read the warning below.

WARNING: This function should be left unchanged. It is only exposed in this codeunit to allow a VAR to add additional permissions to the codeunit for reading and writing the Zetadocs Archive ID value to and from additional tables!

OverrideSendSettings

Apart from setting up the company and contact field number references in the Zetadocs Report Settings there are a number of other options that control the display options and the report batch information settings. During the Initialize function (See Understanding the SDK Framework) these settings are copied in to a temporary table called the Zetadocs Send Settings. This gives us the ability to adjust these settings at runtime. Once the report settings have been copied into the temporary send settings table described, the Zetadocs Send Results Gen codeunit calls the OverrideSendSettings trigger function in the Zetadocs-Send Integration codeunit. Here you can modify the settings based on some logic for that send instance.

  • Report ID: WARNING: This is not for editing. It is here to allow the developer to determine which report is being printed in the trigger and to branch CASE or IF statements depending on its value.
  • Batch Name: In the Zetadocs Report Settings you have the ability to specify Default Batch Name. This is the name that will be displayed in the Zetadocs Client for the report records printed to Zetadocs. This default value can be overridden in this function.
  • Show Delivery Dialog, Show batch Delivery Dialogs, Preview in Zetadocs Client and Test Mode: All these can be dynamically overridden in this trigger at runtime.
  • Company Type Code: Similar to the Report ID, this value is not for editing but is present to allow the developer to determine the target company type configured for this report without having to query the Zetadocs Report Settings Table.

A good example of when you might use this function is if you wish to have a report run uninterrupted by UI dialogs and previewing in the Zetadocs Client if it is being sent during the night. All previews could be turned off.

GetContactForReport

As explained in the previous section, not specifying a Contact No. Field No. means that this function will be called for you to return the value. This means that you are not restricted to extracting the reference directly from the record being reported. The report id, record id and send settings are passed as parameters into this function and therefore you can implement your own custom logic for each report and record type to determine a contact. Note that the return value Code is not typed and is extra long. This means that the code is not tied to a specific NAV type. This will be covered more in the next chapter.

GetCompanyForReport

Similar to GetContactForReport this function allows you to implement custom logic for determining the Company No. value. The report id, record id and send settings are passed as parameters to this function and therefore you can implement your own custom logic for each report and record type to determine a company. Note that the return value Code is not typed and is extra long. This means that the code is not tied to a specific NAV type. This will be covered more in the next chapter.

GetHardCopyPrinter

This function is always called to get the printer to use for the current user when the delivery method is set to Hard Copy. It defaults to using the NAV Printer Selections setting for that user for that report otherwise it uses the user's system default printer. It is provided here to allow you to change this logic.

GetOutputFileName

When a report is printed to Zetadocs, converted to a pdf and sent to a recipient it is desirable to be able to name that pdf file something relevant. This function is called from the AddRecord function in the Zetadocs Send Results Gen codeunit (i.e. once per report record) to allow you to specify independent file names.

GetRecordNoForReport

Similar to the Company No. Field No. and Contact No. Field No. settings in the Zetadocs Report Settings there is an option to specify the Record No. Field No. This field's purpose is primarily for customizing Zetadocs message content. For example it is often desirable to include a Ref. number in the subject of email correspondence. This can be set by adding %%[ZetadocsRecordNo] into the subject of a Zetadocs Template. Once again this field no. reference setting operates similar to Contact No. Field No. such that if the field is left blank in the Zetadocs Report Settings then this function will be called from the AddRecord function in the Zetadocs Send Results Gen codeunit. This may be necessary if your reference number is composed of more than one field value. If so these field values could be concatenated and returned from this function.

GetCompanyRule

This function is exposed here for a number of reasons. Firstly it allows the customization of rules dynamically at runtime but primarily it can used in conjunction with the Company Type Code to provide company rules for bespoke company types (i.e. types other than Customer and Vendor). This is explained in more detail in the next chapter. The important thing to note about this function is the parameter that is passed. The "Zetadocs Company Rule" is another temporary table maintained in the Zetadocs Send Results Gen codeunit. This is used to get the rule override information irrespective of the company type. This will become clearer in the next chapter. It is recommended that you review the implementation of this trigger function in the Zetadocs-Send Integration codeunit to further your understanding.

Last updated 19th August 2013 (MW/)