Equisys technical notes

Technical guidance, explanations and fixes for our products

HOWTO: Automatically capture documents like supplier invoices using barcodes.

Print

ZTN4280

ID: ZTN4280

This Zetadocs technical note applies to:

  • Zetadocs for Microsoft Dynamics NAV

Summary

This document details how to automatically link paper invoices to the corresponding invoice in Microsoft Dynamics NAV and upload that document to the electronic archive. As soon as an invoice has been entered onto NAV, a barcoded label is produced by a small desktop printer for sticking onto the invoice. It can then be scanned and automatically linked to the relevant transaction in NAV.

NOTE: If you intend to scan batches of your barcoded supplier invoices, you will need to split the batch back into its individual parts reliably using the attached Zetadocs barcode splitter page. This process is described below in the Zetadocs Server Configuration section.

Main steps:

1.  Zetadocs Server Configuration

2.  Installing the barcode font

3.  Creating a report that prints a barcode

4.  Add a button to run the print barcode report

5.  Add the AutoLink code

6.  Creating a Document Queue to run the GetAutolink code

7.  Add the Document Queue to the NAV menu suite (in Classic client)

8.  Test Auto Linking

1. Zetadocs Server Configuration

To get supplier invoice processing setup there are a few changes to the Zetadocs Server setup that are required. Zetadocs Server settings are modified using a Config.xml file, this is located in the Zetadocs Server installation location usually C:\Program Files (x86)\Zetadocs Server\Document Converter. Open this file in a text editing program such as Notepad.exe.

Zetadocs Server Setup - Supplier Invoice Processing Settings

The Zetadocs Server settings need to be modified to ensure that barcodes can be properly read and decoded to enable Zetadocs to take actions based on them. Please ensure that the following settings changes have been made to your config.xml file.

Enabling Abbyy

Abbyy is the third party OCR tool which provides Zetadocs with OCR functionality. Set EnableAbbyy to true.

Sample Code: < EnableAbbyy> true< /EnableAbbyy>

Batch Scanning Settings

We advise the use of the Zetadocs barcode splitter page, available , to reliably split scanned batches of documents. The use of sticky barcodes on the supplier invoices both splitting and linking is not recommend. This is because sticky barcodes will sometimes get placed at an angle on the page (rather than horizontally straight), which can lead to the barcode not being detected correctly causing and the document not being split correctly.

Each document queue can be configured to use only one type of splitting method when processing batches of documents. Set BatchScanSplitType to Barcode

Sample Code: < BatchScanSplitType> Barcode< /BatchScanSplitType>     

Barcode Prefixes

When using the Barcode and BarcodeValue splitting methods, a barcode prefix can be set to ensure the Zetadocs Server only splits documents where it finds barcodes that contain a specified prefix. The prefix is defined under the BatchScanBarcodePrefix parameter shown below. Set the BatchScanBarcodePrefix to ZD if using the Zetadocs scan splitter test.docx test page for testing.

Sample Code: < BatchScanBarcodePrefix>ZD< /BatchScanBarcodePrefix>    

Options:

  • Any value can be used as a prefix as long as it only contains non special characters supported by the barcode font, if not using barcodes it can be left blank.
  • Note: The Prefix value is case sensitive.

Enabling Automatic deletion of the split page

When using the Barcode and BarcodeValue splitting methods, if you use a splitting page containing a barcode, you may want to delete the split page. This can be set under the BatchScanBarcodeDeleteSplitPage parameter. This feature is often used when splitter pages have been added throughout a batch to define when each multipage document ends and prevents these pages from ending up in the archive. Set BatchScanBarcodeDeleteSplitPage to true.

Sample Code: < BatchScanBarcodeDeleteSplitPage> true< /BatchScanBarcodeDeleteSplitPage>

Barcode Detection

Zetadocs can detect barcodes if the OCR module has been installed, this option determines whether the Zetadocs Server searches for readable barcodes or not. Set EnableBarcodeDetection to true.

Sample Code:true

2. Installing the barcode font

Barcodes can be added to reports by simply using a suitable font. The chosen barcode font must be installed on each client PC that will be used to print the report. There are many different types of barcode font available, but we have found that Code 39 barcodes work well with Zetadocs. You can download and install a free Code 39 barcode font from http://www.barcodesinc.com/free-barcode-font/. Choose either the standard or extended font and follow the included instructions to install the font on each client PC. Barcode fonts often have limited character support e.g. A-Z and 0-9. So please ensure that the characters you wish to use are supported by the font.

3. Creating a report that prints a barcode

Next we need to create a report which prints a barcode, this can then be printed to a label printer and added to invoices.

  • Create a blank report with a single DataItem > Integer
  • In the Report Designer select View> Sections.
  • Go to toolbox View > Toolbox and add a text box.
  • Right click on the text box and select properties.
  • Set the text box FontName to the barcode font name e.g. FontName = Free 3 of 9 Extended
  • Edit the FontSize, 32 is the recommended minimum font size.
  • Set the text box SourceExpr property to the value to be used for the barcode e.g. (BarcodeValue). Do the same for the DataSetFieldName property.
  • Add another text box below the barcode to display the BarcodeValue in a standard font.

  • Go to View > C/AL Globals.
  • Add BarcodeValue as a variable, with DataType as Text.
  • Add SetBarcodeValue as a Function.
  • View C/AL Code and the following code BarcodeValue := Value;
  • Save the changes to the report.

4. Add a button that prints the barcode

  • In the Development Environment (Classic client), select the Purchase Invoice form or page as required from the Object Designer and click Design.
  • Go to View - Toolbox and add a command button to the form.
  • Right click on the command button and select properties.
  • Add a caption for the button (?Print Barcode?)
  • Adjust settings for font, size etc as required.
  • Close the window.
  • Right click on the command button and select C/AL Code.

In the OnPush section:

  • Add the following lines of code:

BarcodeReport.SetBarcodeValue(FORMAT('*' + " No." + '*'));
BarcodeReport.RUNMODAL;

  • Add a local variable (Go toView > C/AL locals)
    • Name: BarcodeReport
    • DataType:Report
    • Subtype:ZD-Barcode Report
  • Save & compile.

5. Add AutoLink code that will be run from the Document Queue.

  • In the Developement Environment (Classic client), select the Zetadocs Capture Customize code unit from the Object Designer and click Design.
  • In the GetAutoLink section, add the code shown below.

// Autolink with Purchase Invoice documents

// Use the barcodes that are passed in to find the record to link to.

// Call reset to clear any filters that may be on the barcodes temporary table

ZdDocQueueBarcodes.RESET;

IF NOT ZdDocQueueBarcodes.FIND('-') THEN

BEGIN

// There are no barcodes so don't modify the record.

// Processing will fall back to calling the Link function for the manual method.

ZdUtilities.Log(0, 'C9009964 - GetAutoLink - No Barcode found');

EXIT;

END;

barcodeVal := ZdDocQueueBarcodes.Value;

// If the barcode starts with PINN it means it is a Purchase Invoice.

// The barcode will be in the format PINN*****, where 000000 is the Purchase Invoice record number

IF (STRLEN(barcodeVal) > 4) AND (COPYSTR(barcodeVal, 1, 4) = 'PINN') THEN

BEGIN

PurchaseRec.RESET;

//PurchaseRec." No." := COPYSTR(barcodeVal, 5);

PurchaseRec." No." := COPYSTR(barcodeVal, 1);

PurchaseRec." Document Type" := PurchaseRec." Document Type" ::Invoice;

// If we can find the record that the barcode refers to

IF PurchaseRec.FIND THEN

BEGIN

// if the user selected a record use a RecordRef to get the RecordID for the record

// and modify the ZdLinkResult record to include it

RecRef.GETTABLE(PurchaseRec);

ZdLinkResult." Record ID" := RecRef.RECORDID;

ZdLinkResult.MODIFY;

END;

END;

  • Ensure local variables as shown below are specified (View > C/AL Locals).

  • Save & compile.

6. Creating a Document Queue to run the GetAutolink code

Before creating a document queue in NAV, note the following:

  • A shared network folder needs to be created where the purchase invoices will be scanned into, all users of the document queue will need full access to this location.
  • Archiving to SharePoint should be enabled by navigating to Application Setup > Zetadocs Setup > Advanced Settings > Zetadocs System Settings, before setting up the document queue.
  • An action needs to be added to the Zetadocs Doc. Queue Actions Table e.g. ID: ZDPINV, Description: Link to Purchase Invoice.

To configure a document queue in the NAV Classic client:

  • Open NAV and select the Administration option from the Navigation Pane.
  • Navigate to Application Setup > Zetadocs Setup > Advanced Settings > Zetadocs Document Queue Setup.

7. Adding the Document Queue to the NAV menu suite (in Classic client)

  • Open the Object Designer and select the Menusuite option.
  • Highlight the object with ID 1055 called Dept - Zetadocs for NAV and select Design.
  • Navigate to the location where you want to add the queue in the navigation pane, right click and select Create Item.
  • Input properties like those shown below.

  • Save the changes to complete your setup.

8. Testing document Auto Linking

At this stage you should test that the functionality you have added works by doing the following:

  • Modify Zetadocs scan splitter test.docx to include relevant NAV record IDs
  • Scan the printed Zetadocs scan splitter test.docx into your new document queue
  • Check that the document is listed in the document queue within NAV and can be viewed correctly.
  • Check that the scanned document displays the appropriate text in the Link column.
  • Click the Archive button and complete the actions.
  • Browse to the SharePoint library and check that the document has been archived successfully in the correct location.
  • Finally, when you have completed your testing delete any test documents from the archive.

References

HOWTO: Ensure barcode values are detected correctly by OCR in the Zetadocs Server Document Converter

Last updated: 21st September 2015 (DC) 

Keywords:

Equisys Logo, Document Management and Expense Management for Business Central
 

Replaced by script