Search code examples
kofax

Kofax - Custom Export Connector - Order of methods


We have written a custom Export Connector for our purposes that doesn't seem to be working as expected for a select, few cases.

According to the Kofax Capture 10.0 Developer's Guide, the Export module loads the export connector and does the following:

1. Fills in the general batch class and document class properties in the ReleaseData variable.
2. Calls the OpenScript method. You should use this method to perform any initialization required for the connector.
3. Fills in the properties specific to the first document to be exported in the ReleaseData variable and calls the ReleaseDoc method for the document. You should use this method to save the document data in the external database and copy the image files and full text OCR files to the selected export folders.
4. Repeats the process described in Step 3 for each remaining document to be exported.
5. Calls the CloseScript method after the last ReleaseDoc method is completed and the connector is about to be unloaded. You should use this method to perform any cleanup required for the connector.

So if I understand correctly, the OpenScript method is called first and the CloseScript method is only called after each document is released via the ReleaseDoc method.

However, by setting breakpoints in Visual Studio, we observe that this is not the case for our connector in a few, specific cases, namely when we have a document of document class A and a document of document class B, both belonging to the same batch class. What happens is:

Document A: OpenScript --> ReleaseDoc --> CloseScript
Document B: OpenScript --> ReleaseDoc --> CloseScript

What we would like to happen (if at all possible) is:

OpenScript --> ReleaseDoc for Document A --> ReleaseDoc for Document B --> CloseScript

Our INF file for Export Connector registration contains (among other lines) the following line:

SupportsMultipleInstances=False

My question is, thus, as follows: is there any way to change the behavior of the Export module such that it releases all documents within the same batch before invoking CloseScript?


Solution

  • OpenScript fires for every Document Class when the class is first encountered during the Export stage. Since export connectors are not tied to batch classes but document classes and batch classes, this will always happen.

    To accomplish what you need, you'll have to setup a file or registry entry that is set the first time OpenScript runs for the batch and any subsequent runs of the function are skipped until the batch is closed.