Indexing - Barcode Processing Scripts

The normal Barcode Mapping and Barcode Parsing option on the Document Index Fields screen are usually sufficient for populating index fields. However, if your barcode processing requirements are too complex for these options, check the "Use Barcode Processing Script" checkbox and press the Open Script Editor button. This option is available in Document Index Fields and Folder Index Fields:

 

 

The methods for both folder and document index field processing are accessed through the BarcodeProcessingScript class.

BarcodeProcessingScript Class

ProcessDocumentBarcodeData Method

The ProcessDocumentBarcodeData method is called whenever a new document is created.

Parameters:

 

Directions Parameter Type Descriptions
IN document IDocument The current document
barcodes list of IBarcode The list of barcodes detected on the document's separator sheet
Example – Check each barcode for a valid PO number. If found, store the number in the document’s notation.
public virtual void ProcessDocumentBarcodeData(IDocument document, IEnumerable<IBarcode> barcodes)
{
  try
  {
    string poNumberText = string.Empty;
    // Locate the Purchase Order barcode
 	foreach(IBarcode barcode in barcodes)
    {
      if(barcode.Value.StartsWith("PO", StringComparison.CurrentCultureIgnoreCase))
      {
        // Store the barcode's value, removing the leading letters "PO"
        poNumberText = barcode.Value.Substring(2).Trim();
        // Verify that the remaining characters make up a valid integer.
        // If so, we've found the value we need, so stop the foreach loop.
        int poNumber;
        if(int.TryParse(poNumberText, out poNumber))
          break;
        // The text was no a valid PO number, so reset the local varriable and keep searching.
        poNumberText = string.Empty;
      }
    }
    // Set the document's notation value to the PO number (or to blank if none was found)
    document.DocumentNote = poNumberText;
  }
  catch (Exception exception)
  {
    base.ProcessException(exception);
  }
}

 

ProcesFolderBarcodeData Method

The ProcessFolderBarcodeData method is called whenever a new folder is generated.

Parameters:

 

Direction Parameter Type Description
IN folder IFolder The current folder
barcodes IBarcode The list of barcodes detected on the folder's separator sheet
Example – Locate the first Data Matrix barcode on the page (if any). If found, set the folder’s note value to the value of the barcode.
public virtual void ProcessFolderBarcodeData(IFolder folder, IEnumerable<IBarcode> barcodes)
{
  try
  {
    // Find the first Data Matrix barcode in the list of barcodes
    IBarcode dataMatrixBarcode = barcodes.FirstOrDefault(b => b.Type == BarcodeTypes.DataMatrix);
    if(dataMatrixBarcode != null)
      folder.FolderNote = dataMatrixBarcode.Value;
  }
  catch (Exception exception)
  {
    base.ProcessException(exception);
  }
}
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.