KTM ChangeClass method used from Batch CLose
Public Sub DocumentClassRouting(ByVal pXRootFolder As CASCADELib.CscXFolder)
On Error GoTo ErrorHandler
LogMessage "Scansation.DocumentClassRouting"
' Check document conditions & perform any final re-classifications
Dim i, j, k As Long
Dim oXDocInfo As CscXDocInfo
Dim oXValue As CscXValue
Dim oResults As CscXDocField
Dim sDIC_Code As String
Dim sKtmClassName As String
Dim bClassChanged As Boolean
Set oResults = GetSqlResults("KofaxTransformation", "SELECT * FROM SettingsClient_DocumentClassRouting WHERE ProjectID = ? AND ClientID = ? ORDER BY DIC_Priority", Array(tDocDefClassify.ProjectID, gbl_ClientID))
If oResults.Alternatives.Count > 0 Then
' *** DOCUMENT DATA (LOOSE) ***
For i = 0 To pXRootFolder.DocInfos.Count - 1
LogMessage "Scansation.Document " & CStr(i+1)
' For each document, we need to check for the existence of document integrity conditions based on the provided rules
Set oXDocInfo = pXRootFolder.DocInfos.ItemByIndex(i)
bClassChanged = False
' For each of the rules provided, get the condition code (results are in order of priority).
For j = 0 To oResults.Alternatives.Count - 1
sDIC_Code = oResults.Alternatives.ItemByIndex(j).SubFields.ItemByName("DIC_Code").Text
sKtmClassName = oResults.Alternatives.ItemByIndex(j).SubFields.ItemByName("KtmClassName").Text
' Check for matching DIC codes; Example: SS_CUSTOM_DIC_002
For k = 0 To oXDocInfo.XValues.Count - 1
Set oXValue = oXDocInfo.XValues.ItemByIndex(k)
If InStr(oXValue.Key, "SS_CUSTOM_DIC_") > 0 Then
If oXValue.Value = sDIC_Code Then
LogMessage "Scansation.DIC Code match, changing class..."
If KtmClassExists(sKtmClassName) Then
Batch.ChangeClass(sKtmClassName, oXDocInfo, False)
bClassChanged = True
Exit For
End If
End If
End If
Next
If bClassChanged = True Then Exit For
Next
Next
End If
Exit Sub
ErrorHandler:
LogError(Err.Number, "DocumentClassRouting", Err.Description)
End Sub