vbakofax

Kofax KTM Validation Routing


I'm working on a Kofax KTM project, that have multiple Validation steps. After the KTM Server Module the batch will be routed to another validation step depending on the Batch name.

Now the routing works well, but if its not the first validation step the following error occurs:

Validation Message

Anyone an idea how to fix this? thx

Here is my code:

' Rout Document to the Correct Validation step.
Private Sub Batch_Close(ByVal pXRootFolder As CASCADELib.CscXFolder, ByVal CloseMode As 
CASCADELib.CscBatchCloseMode)
   Dim i As Long
   Dim mandat As String
   Dim lVal As Long
   Dim strVal As String
   Dim oXDocInfo As CASCADELib.CscXDocInfo
   Dim folder As CASCADELib.CscXFolder

   ' only enter after extraction and after validation
If CloseMode = CASCADELib.CscBatchCloseFinal Then
  If Project.ScriptExecutionMode = CscScriptModeServer Or Project.ScriptExecutionMode = CscScriptModeValidation Then
           ' get root folder
     Set folder = pXRootFolder
     While Not folder.IsRootFolder
        Set folder = folder.ParentFolder
     Wend

     ' get batch name
     mandat = folder.XValues.ItemByName("AC_BATCH_CLASS_NAME").Value
     lVal = 0
     strVal = ""

     Select Case mandat
        Case "x"
           lVal = 0
        Case "y"
           lVal = 2
     End Select

     strVal = CStr(lVal)

     If Project.ScriptExecutionMode = CscScriptModeValidation Then
        For i = 0 To folder.GetTotalDocumentCount - 1
           Set oXDocInfo = folder.GetDocInfoByGlobalIndex(i)
           oXDocInfo.XValues.Set("KTM_DOCUMENTROUTING", strVal)
        Next
        folder.XValues.Set("KTM_DOCUMENTROUTING_QUEUE_" & strVal, "kfxpdf.exe")
     ElseIf Project.ScriptExecutionMode = CscScriptModeServer Then
        For i = 0 To folder.GetTotalDocumentCount - 1
           Set oXDocInfo = folder.GetDocInfoByGlobalIndex(i)
           oXDocInfo.XValues.Set("KTM_DOCUMENTROUTING", strVal)
           oXDocInfo.XDocument.NextValidationInstance = lVal
        Next
        ' validation is not done => rout to the depending validation instance
        If(lVal = 0) Then
           folder.XValues.Set("KTM_DOCUMENTROUTING_QUEUE_" & strVal, "KTM.Validation")
        Else
           folder.XValues.Set("KTM_DCOUMENTROUTING_QUEUE_" & strVal, "KTM.Validation")
           folder.XValues.Set("KTM_DOCUMENTROUTING_QUEUE_" & strVal, "KTM.Validation" & strVal)
           pXRootFolder.Valid = False
        End If
     End If
  End If
End If
End Sub

Solution

  • I found the problem:

    The value of KTM_DOCUMENTROUTING_QUEUE_ must not be the same like the next validation instance...

    so thats the code that works:

    Private Sub Batch_Close(ByVal pXRootFolder As CASCADELib.CscXFolder, ByVal CloseMode As CASCADELib.CscBatchCloseMode)
    Dim i As Long
    Dim mandat As String
    Dim lVal As Long
    Dim strVal As String
    Dim oXDocInfo As CASCADELib.CscXDocInfo
    Dim folder As CASCADELib.CscXFolder
    
    ' only enter after extraction and after validation
    If CloseMode = CASCADELib.CscBatchCloseFinal Then
      If Project.ScriptExecutionMode = CscScriptModeServer Or Project.ScriptExecutionMode = CscScriptModeValidation Then
               ' get root folder
         Set folder = pXRootFolder
         While Not folder.IsRootFolder
            Set folder = folder.ParentFolder
         Wend
    
         ' get batch name
         mandat = folder.XValues.ItemByName("AC_BATCH_CLASS_NAME").Value
         lVal = 0
         strVal = ""
    
         Select Case mandat
            Case "x"
               lVal = 0
            Case "y"
               lVal = 1
         End Select
    
         strVal = CStr(lVal)
            folder.XValues.Set("KTM_DOCUMENTROUTING_QUEUE_" & strVal, "kfxpdf.exe")
         ElseIf Project.ScriptExecutionMode = CscScriptModeServer Then
            For i = 0 To folder.GetTotalDocumentCount - 1
               Set oXDocInfo = folder.GetDocInfoByGlobalIndex(i)
               oXDocInfo.XValues.Set("KTM_DOCUMENTROUTING", strVal)
               oXDocInfo.XDocument.NextValidationInstance = lVal
               oXDocInfo.XDocument.Valid = False
            Next
            ' validation is not done => rout to the depending validation instance
            If(lVal = 0) Then
               folder.XValues.Set("KTM_DOCUMENTROUTING_QUEUE_" & strVal, "KTM.Validation")
            Else
               folder.XValues.Set("KTM_DCOUMENTROUTING_QUEUE_" & strVal, "KTM.Validation")
               folder.XValues.Set("KTM_DOCUMENTROUTING_QUEUE_" & strVal, "KTM.Validation" & CStr(lVal + 1))
               pXRootFolder.Valid = False
            End If
         End If
      End If
    End If
    End Sub