Scripting - Batch XValues
Issue
How can be Kofax Capture Batch values (such as Batch creation site name etc.) accessed in Kofax Transformation Modules, for example to perform some Batch routing
Solution
This article describes what Kofax Capture Batch values are available and how to access them in KTM script.
The following batch properties are accessible from script (XRootFolder.XValues.ItemByName (XValue key
):
Batch Property | XValue key |
Batch Name (read-only) | AC_BATCH_NAME |
Batch Class Name (read-only) | AC_BATCH_CLASS_NAME |
Priority (read/write) | AC_BATCH_PRIORITY |
ImageDirectory (read-only) | AC_IMAGE_DIRECTORY |
ExternalBatchID (read-only) | AC_EXTERNAL_BATCHID |
BatchGUID (read-only) | AC_BATCH_GUID |
BatchCreationDateTime (read-only) | AC_BATCH_CREATIONDATETIME |
CreationSiteName (read-only) | AC_BATCH_CREATIONSITENAME |
CreationUserID (read-only) | AC_BATCH_CREATIONUSERID |
OperatorUserID (user ID of last batch history entry) (read-only) | AC_BATCH_OPERATORUSERID |
UserID (read-only) | AC_BATCH_USERID |
UserName (read-only) | AC_BATCH_USERNAME |
WindowsUserName (read-only) | AC_BATCH_WINDOWSUSERNAME |
Components
Script Locator
Option Explicit ' Class script: Base Private Sub Script_LocateAlternatives(ByVal pXDoc As CASCADELib.CscXDocument, ByVal pLocator As CASCADELib.CscXDocField) '## XValues '## Script locator alternative pLocator.Alternatives.Create pLocator.Alternatives(0).Confidence = 1 '## Alternative subfields '## Batch information ## For more information see the 'Help for Kofax Transformation - Scripting -- Applying Scripting - Accessing Kofax Capture Data' pLocator.Alternatives(0).SubFields.Create("AC_BatchName") 'Read only pLocator.Alternatives(0).SubFields.Create("AC_BatchClassName") 'Read only pLocator.Alternatives(0).SubFields.Create("AC_BatchPriority") 'Read/Write pLocator.Alternatives(0).SubFields.Create("AC_BatchDirectory") 'Read only Documentation uses the variable name: AC_BATCH_DIRECTORY and the software uses the name: AC_IMAGE_DIRECTORY pLocator.Alternatives(0).SubFields.Create("AC_BatchExtarnalBatchID") 'Read only Documentation uses the variable name: AC_BATCH_EXTERNAL_BATCHID and the software uses the name: AC_EXTERNAL_BATCHID pLocator.Alternatives(0).SubFields.Create("AC_BatchGUID") 'Read only pLocator.Alternatives(0).SubFields.Create("AC_BatchCreationDateTime") 'Read only pLocator.Alternatives(0).SubFields.Create("AC_BatchCreationSiteName") 'Read only pLocator.Alternatives(0).SubFields.Create("AC_BatchCreationUserID") 'Read only pLocator.Alternatives(0).SubFields.Create("AC_BatchOperationUserID") 'Read only (user ID of last batch history entry) pLocator.Alternatives(0).SubFields.Create("AC_BatchUserID") 'Read only pLocator.Alternatives(0).SubFields.Create("AC_BatchUserName") 'Read only pLocator.Alternatives(0).SubFields.Create("AC_BatchWindowsUserName") 'Read only '# Batch information is stored in the XRootFolder, i.e. the KTM batch information file Dim pXRootFolder As CscXFolder Set pXRootFolder = GetRootFolder(pXDoc.ParentFolder) BatchInfo(pXRootFolder, "AC_BATCH_NAME", pLocator, "AC_BatchName") BatchInfo(pXRootFolder, "AC_BATCH_CLASS_NAME", pLocator, "AC_BatchClassName") BatchInfo(pXRootFolder, "AC_BATCH_PRIORITY", pLocator, "AC_BatchPriority") BatchInfo(pXRootFolder, "AC_IMAGE_DIRECTORY", pLocator, "AC_BatchDirectory") BatchInfo(pXRootFolder, "AC_EXTERNAL_BATCHID", pLocator, "AC_BatchExtarnalBatchID") BatchInfo(pXRootFolder, "AC_BATCH_GUID", pLocator, "AC_BatchGUID") BatchInfo(pXRootFolder, "AC_BATCH_CREATIONDATETIME", pLocator, "AC_BatchCreationDateTime") BatchInfo(pXRootFolder, "AC_BATCH_CREATIONSITENAME", pLocator, "AC_BatchCreationSiteName") BatchInfo(pXRootFolder, "AC_BATCH_CREATIONUSERID", pLocator, "AC_BatchCreationUserID") BatchInfo(pXRootFolder, "AC_BATCH_OPERATORUSERID", pLocator, "AC_BatchOperationUserID") BatchInfo(pXRootFolder, "AC_BATCH_USERID", pLocator, "AC_BatchUserID") BatchInfo(pXRootFolder, "AC_BATCH_USERNAME", pLocator, "AC_BatchUserName") BatchInfo(pXRootFolder, "AC_BATCH_WINDOWSUSERNAME", pLocator, "AC_BatchWindowsUserName") End Sub Private Function BatchInfo(ByVal RootFolder As CscXFolder, ByVal sBatchInfo As String, ByVal Locator As CscXDocField, ByVal sSubFieldName As String) As CscXDocSubField Set BatchInfo = Locator.Alternatives(0).SubFields.ItemByName(sSubFieldName) If RootFolder.XValues.ItemExists(sBatchInfo) Then BatchInfo.Text = RootFolder.XValues.ItemByName(sBatchInfo).Value BatchInfo.ExtractionConfident = True BatchInfo.Confidence = 1 End If End Function Public Function GetRootFolder(pXFolder As CASCADELib.CscXFolder) As CASCADELib.CscXFolder If pXFolder.IsRootFolder Then Set GetRootFolder = pXFolder Else Set GetRootFolder = GetRootFolder(pXFolder.ParentFolder) End If End Function
Note that this example was created on a workstation environment and not a client/server environment, therefore the user IDs and names are all the same.
Level of Complexity
Moderate
Applies to
Product | Version | Build | Environment | Hardware |
---|---|---|---|---|
Kofax Transformation Modules | All |
References
XValue: https://docshield.kofax.com/KTM/en_US/6.4.0-uuxag78yhr/help/SCRIPT/ScriptDocumentation/c_XValue.html
Batch data: https://docshield.kofax.com/KTM/en_US/6.4.0-uuxag78yhr/help/SCRIPT/ScriptDocumentation/c_BatchData.html
Document data: https://docshield.kofax.com/KTM/en_US/6.4.0-uuxag78yhr/help/SCRIPT/ScriptDocumentation/c_DocumentData.html
Article # 3035877