With Kofax Capture you can enter document index values in a validation screen or just confirm or changes values which have been recognized automatically. The validation screen form presents all fields of a document and the user has to confirm/change field values or enter data.
This is cumbersome and unnecessary for those kind of fields which have been filled automatically by barcode (see: “Kofax Capture – Document Separation and Barcodes“) or OCR , as the validity of these values can often be checked by simple rules or checks against databases.
Kofax Capture (Ascent Capture) always provided a scripting language to implement such checks: Softbridge Basic Language – SBL. This is a computer language from the 90s which is compatible to the old Visual Basic.
In the meantime Kofax Capture also supports C# and VB.NET for scripting within the validation module. The Softbridge Basic Language was deprecated with the current version 10.x of Kofax Capture. SBL might not be available anymore in the next main release of Kofax Capture.
Today most developers are using C# or VB.NET for new validation scripting, but a lot of Kofax Capture installations still exists, which are using SBL scripting in validation. During the migration of some of our older installations, I noticed that the official Kofax documentation for validation scripting with .NET is not very detailed and internet searching showed only fragments of a solution. So I decided to write this article to compare SBL and VB.NET scripting.
SBL has the advantage to be available out of the box as part of the Kofax Capture solution. With minimal efforts you can implement simple validation checks such as length verification in a short time.
If you want to use VB.NET or C# for validation scripting, you first have to install Visual Studio on a Kofax Capture admin workstation. You have to look at the Kofax Capture Developers Guide of the installed Kofax Capture version, to see what versions of Visual Studio are supported. I am using Kofax Capture 10.2 and Visual Basic 2010 for the following examples.
The naming of events in SBL and VB.NET
The following table shows the most important and most used events for scripting within the Kofax validation. For each event the table shows the internal event name of the SBL environment (Functions) and of the new VB.NET environment (Subs).
This example has two fields at document class level: ‘Barcode’ and ‘Status’:
Event | SBL-name | VB.Net-name |
Batch open | KfxLoadValidation | Validation_BatchLoading |
batch close | KfxUnloadValidation | Validation_BatchUnloading |
Document open | KfxDocPreProcess | DocPreProcessing |
Document close | KfxDocPostProcess | DocPostProcessing |
Field Barcode open | PreBarcode | Barcode_FieldPreProcessing |
Field Barcode close | PostBarcode | Barcode_FieldPostProcessing |
Field Status open | PreStatus | Status_FieldPreProcessing |
Field Status close | PostStatus | Status_FieldPostProcessing |
I just skip the SBL scripting example and show the appropriate part of the VB.NET script.
- A message box was included in each event – so you can check the program sequence
- The Barcode field contains a simple length check
' Class script: Project
Imports Kofax.AscentCapture.NetScripting
Imports Kofax.Capture.CaptureModule.InteropServices
Imports System
Imports System.Collections.Generic
Imports System.Text
Namespace ExampleDocClass
<SuppressFieldEventsOnDocClose(false)> _
Public Class ExampleDocClass
Inherits DocumentValidationScript
<IndexFieldVariableAttribute("Barcode")> _
Dim WithEvents Barcode As FieldScript
<IndexFieldVariableAttribute("Status")> _
Dim WithEvents Status As FieldScript
'--------------------------------------
Private Sub Barcode_FieldPostProcessing(ByVal sender As Object, ByVal e As Kofax.AscentCapture.NetScripting.PostFieldEventArgs) Handles Barcode.FieldPostProcessing
Try
If Len(Barcode.IndexField.Value) <> 6 Then
Throw New Kofax.AscentCapture.NetScripting.ValidationErrorException("Barcode nur 6-stellig!", Barcode.IndexField)
End If
Finally
End Try
End Sub
'--------------------------------------
Private Sub Barcode_FieldPreProcessing(ByVal sender As Object, ByVal e As Kofax.AscentCapture.NetScripting.PreFieldEventArgs) Handles Barcode.FieldPreProcessing
MsgBox("Barcode_FieldPreProcessing")
'This will skip the field
'e.SkipMode = PreFieldEventArgs.SkipModeEnum.SaveAndSkipField
End Sub
'--------------------------------------
Private Sub Status_FieldPostProcessing(ByVal sender As Object, ByVal e As Kofax.AscentCapture.NetScripting.PostFieldEventArgs) Handles Status.FieldPostProcessing
MsgBox(Status.IndexField.Value)
End Sub
'--------------------------------------
Private Sub Status_FieldPreProcessing(ByVal sender As Object, ByVal e As Kofax.AscentCapture.NetScripting.PreFieldEventArgs) Handles Status.FieldPreProcessing
MsgBox("Status_FieldPreProcessing")
'This will skip the field **********************
'e.SkipMode = PreFieldEventArgs.SkipModeEnum.SaveAndSkipField
End Sub
'--------------------------------------
Private Sub DocPostProcessing(ByVal sender As Object, ByVal e As Kofax.AscentCapture.NetScripting.PostDocumentEventArgs) Handles Me.DocumentPostProcessing
MsgBox("DocPostProsessing")
End Sub
'--------------------------------------
Private Sub DocPreProcessing(ByVal sender As Object, ByVal e As Kofax.AscentCapture.NetScripting.PreDocumentEventArgs) Handles Me.DocumentPreProcessing
MsgBox("DocPreProsessing")
'This will SaveAndSkip the document **********************
'e.SaveAndSkip = True
End Sub
'--------------------------------------
Private Sub Validation_BatchLoading(ByVal sender As Object, ByVal e As Kofax.AscentCapture.NetScripting.BatchEventArgs) Handles Me.BatchLoading
MsgBox("Validation_BatchLoading")
End Sub
'--------------------------------------
Private Sub Validation_BatchUnloading(ByVal sender As Object, ByVal e As Kofax.AscentCapture.NetScripting.BatchEventArgs) Handles Me.BatchUnloading
MsgBox("Validation_BatchUnloading")
End Sub
Sub New(ByVal bIsValidation As Boolean, ByVal strUserID As String, ByVal strLocaleName As String)
MyBase.New(bIsValidation, strUserID, strLocaleName)
End Sub
End Class
End Namespace
|
Finally we need the often used SaveAndSkipField (skip a field in validation) and SaveAndSkipDocument (skip a document in validation) functionality in the VB.NET environment. This has been put into the above scripting code as comments:
- For fields in the event Fieldname_FieldPreProcessing:
e.SkipMode = PreFieldEventArgs.SkipModeEnum.SaveAndSkipField - For documents in the event DocPreProcessing:
e.SaveAndSkip = True
Details about Kofax Capture .NET Scripting can be found in the ‘Kofax Capture API Reference’, which is part of the documentation.
More blog articles about KC und KTM:
Automatic termination of an insurance contract – how Kofax KTM may help
Kofax Transformation Modules: SEPA Mandates and handwritten additional information – or: who scribbled on my form?
Kofax Transformation Modules (KTM): ‘free-form recognition’ for handwritten numbers
Kofax Capture – Document Separation and Barcodes
KTM and insurance companies: Document Process Automation
Document classification with Kofax Transformation Modules (KTM)
Kofax Transformation Modules – format locators and dynamic regular expressions – Part 2
Kofax Transformation Modules – format locators and dynamic regular expressions
IBM Content Collector for SAP (formerly known as IBM CommonStore for SAP), Kofax Capture 10 and the IBM CommonStore Release Script