Simple Uses of Captiva’s Multi Module – Part 2

In this post I demonstrate a simple CaptureFlow script to split pages into documents when a Patch 3 separator sheet is encountered. Refer to the previous post for details regarding the desired Patch 3 behavior. For context, the CaptureFlow snippet is repeated here.

The Multi module can be used to modify the Captiva node tree and convert pages into documents by “splitting” the list of page nodes into a list of documents with single pages. Perhaps the easiest way to understand this behavior and the desired outcome is to examine the graphic below.  When the Patch 3 sheet is encountered in the node tree on the left, it is deleted and a level 1 node is inserted before every following level 0 node, until another level 1 node is encountered or the end of the batch.


To create a CaptureFlow script in Captiva Designer, click the Multi module step that will implement this function (ProcessPatch3 in my CaptureFlow depicted above), and choose Scripting… from the drop down menu. The CaptureFlow scripting editor will open. The following VB code implements the required functionality.

Imports System
Imports Emc.InputAccel.CaptureFlow

Public Partial Class MultiTest

' #1 – execute before module is triggered
Public Shared Sub ProcessPatch3_Prepare (node As IBatchNodeData)
  Dim docs As IBatchNodeData()
  Dim pages As IBatchNodeData()
  Dim patchcode As String = ""
  Dim imgProc As IBatchNodeData
  Dim has_Patch_3 As Boolean = False

  ' define Multi constants
  Dim IAMULTI_DELETE As Int16 = 16
  Dim IAMULTI_READY As Int16 = 8

  On Error Resume Next

  ' #2 - get collection of all documents in batch
  docs = node.GetDescendantNodes(1)
  For Each doc As IBatchNodeData In docs

    ' #3 - get collection of pages from each document
    pages = doc.GetDescendantNodes(0)

    ' #4 - evaluate each page
    For Each page As IBatchNodeData In pages

      ' #5 – get patch code from Image Processor step
      imgProc = page.GetStepNode("ImageProcessor")
      patchcode = imgProc.ReadString("Patchcode")

      ' #6 – if this page is patch code, set flag and delete
      ' this page
      If patchcode.Equals("3") Then
        has_Patch_3 = True

      ' #7 – otherwise process it accordingly
        If has_Patch_3 = True Then
        End If
      End If
    has_Patch_3 = False
End Sub
End Class

Here is how this code works:

  1. The CaptureFlow script editor automatically creates the _Prepare() and _Finish() methods for your module. Because I want to set all of the trigger values before the Multi module is executed, I implement this logic in the _Prepare() method.
  2. Get all of the documents in the batch into a collection.  This is accomplished by passing 1 as the level parameter to the GetDescendantNodes() method.  The node object here is essentially the entire Captiva node tree as it is being sent to the RemoveEmptyDocs step.
  3. For each document in the collection, get a collection of its pages.  This code uses the same GetDescendantNodes() method as step 2, but now the “node” it is operating on is a document retrieved in step 2, and the level parameter is 0 (pages).
  4. For each page in the collection, evaluate each page.
  5. Reach back to the ImageProcessing step for each page to retrieve the Patchcode value for this page.  Patchcode is a standard level 0 IA value.
  6. If patchcode equals 3, I have found a Patch 3 sheet. Set the global variable, has_Patch_3 = true and delete this page.
  7. If patchcode is empty or some other value, then check to see if a patch code has been encountered in this document (i.e., has_Patch_3 = true). If so, split this page into its own document using the Ready trigger value 1. Otherwise, the page gets the default Ready value of 8.


These past couple of posts (0,1) have demonstrated some simple uses of the Captiva Multi module.  In particular, they have demonstrated how to manipulate the Captiva node tree to delete unwanted pages and documents, or to restructure the node tree based on patch codes.  The essence of both implementations, that is using IA Value assignments and CaptureFlow scripting, is the same:  assign each page’s Multi Ready trigger the no-op value (8), and then change it accordingly as conditions dictate.  The primary difference between the IA Value assignment and the CaptureFlow scripting approaches is that the CaptureFlow script is able to persist the state of the patch code while examining the page nodes of a document.  It uses this persisted state to determine whether or not to “split” the node into a document or not.  This type of persistence is not possible using IA Value assignment.

If you have other cool examples of using Captiva’s Multi module I’d like to hear about them.


About Scott
I have been implementing Documentum solutions since 1997. In 2005, I published a book about developing Documentum solutions for the Documentum Desktop Client (ISBN 0595339689). In 2010, I began this blog as a record of interesting and (hopefully) helpful bits of information related to Documentum, and as a creative outlet.

One Response to Simple Uses of Captiva’s Multi Module – Part 2

  1. Pingback: Simple Uses of Captiva’s Multi Module – Part 1 | dm_misc: Miscellaneous Documentum Information

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: