Equisys technical notes

Technical guidance, explanations and fixes for our products

HOWTO: Use the Zetadocs for NAV SDK to deliver NAV reports with additional related attachments that are unique to the recipient



ID: ZTN4019

This Zetadocs technical note applies to:

  • Zetadocs for NAV v1.2
  • Microsoft Dynamics NAV 5.0


This article demonstrates how you can use the Zetadocs for NAV SDK’s GetAdditionalEmbComms function to return additional documents which are combined with the printed NAV report into a single PDF. This will then be sent to the NAV recipient.

Out of the box you can use Zetadocs templates to attach common documents like Conditions of sale and purchase, however in order to attach documents only related to a specific NAV record, you’ll need to implement business logic in the Zetadocs for NAV SDK. This is useful where there are supporting documents like Work specification drawings or RFPs that need to be sent with to the Quote, Order or Invoice.

The code in this article focuses on related PDF documents referenced in the NAV Record links table, but the logic can be extended to incorporate your document structures within NAV as long as the documents to be attached are already in PDF format and accessible to the Zetadocs client.

The Zetadocs for NAV SDK is a chargeable add-on to Zetadocs.

More information

  1. From the Object Designer, open Codeunit 9009962: Zetadocs-Customize
  2. In the Trigger: GetAdditionalEmbComms create the following C/AL Local Variables

  3. NameDataType  Subtype  Length
    a.  LinksRecordRecord link
    b.  ZetadocsUtilitiesCodeunitZetadocs-Utilities
    c.  PathText250

  4. In the Trigger: GetAdditionalEmbComms create the following C/AL Local Text Constants

  5. NameConstValue
    a.  doubleSlash  \\\         (Note: Will become ‘\\’ when you leave Const Value field)

  6. In the Trigger: GetAdditionalEmbComms paste the following C/AL Code. Please read through the code and comments to understand the process.
  7. //

    // We can use the parameters to check for conditions on adding the links attachments

    // in this case we only add for report 9009962


    CASE ZdSendSettings." Report ID" OF

      9009962: //Zetadocs-Order Confirmation



          //Look up links from table


          Links.SETFILTER(" Record ID" ,  FORMAT(Record));


          //If any links to add


          IF Links.FIND('-') THEN



              //Network file - links prefix with 'file://'.This disrupts Zetadocs so it must be removed.

              //Local file - These fine but realise they will not be available to other users on a different machine

              //Internet URLs - are not supported by the Zetadocs Attachments command and should be filtered out if you are storing

              //any in your links.


              Path := Links.URL1;

              IF NOT ( STRPOS(Path, 'file://') = 0) THEN



                  //Get Path without 'file://' prefix


                  Path :=  COPYSTR(Path, 8);



              //If network path '\\' then need to remove it and re-add it.

              //This is a work around for writing '\\' onto a report without getting 2 newlines.

              //FormatPathForOutput - replaces '\' with '\\' to give valid path to Zetadocs.


              IF (Path[1] = '\') AND (Path[2] = '\') THEN


                  //If its a network path we have to manually add the double slash

                  Path := COPYSTR(Path, 3);

                  Path := ZetadocsUtilities.FormatPathForOutput(Path);

                  Path := DoubleSlash + Path;




                  Path := ZetadocsUtilities.FormatPathForOutput(Path);



              //Finally write the embedded command

              //NOTE: You may want to check the file extensions to ensure only .pdf or .zda files are passed to Zetadocs

              //as these are the only supported file types for the Attachment command.


              commands := commands + '%%[Attachment:' + Path + ']' + '\';

            UNTIL Links.NEXT = 0;

        END; //9009962


    ZdAction := ZdAction::Continue;


  8. Modify the code to implement your own logic for adding the links.
  9. Save and Compile the Codeunit.

You are now ready to test your work.

  1. Add links to a record for which your chosen reports will print. Note: In the example above the code will only pull attachments linked to the Sales Header and not the Sales Lines.

    e.g. Link ID 9 will not be added.

  3. Run the Zetadocs report, in this case Order Confirmation and select preview.
  4. You should now see additional embedded commands in the report preview for each of the associated links. Note the second group of embedded commands in the middle of the page. These are the additional embedded commands.

  5. Figure 1 - Additional Embedded Commands Preview

  6. Next Print the report again but print to the Zetadocs PDF Printer and verify that the link attachments are added to the report document.


Use the Zetadocs for NAV Customization guide for further details on the functions used in this article.

Last updated: 26 September 2008 (GC/MW)

Equisys Logo, Document Management and Expense Management for Business Central

Recent news

It may seem strange, in an article extolling the vision of an automated digital future, to start with a reference to 1975, but that was the year Business Week magazine published an article looking ...

This article describes the new features and other improvements in the February 2021 update of the Zetadocs Expenses service. Zetadocs Expenses Release ...