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
1' Class script: Project
2Imports Kofax.AscentCapture.NetScripting
3Imports Kofax.Capture.CaptureModule.InteropServices
4Imports System
5Imports System.Collections.Generic
6Imports System.Text
7
8Namespace ExampleDocClass
9
10 <SuppressFieldEventsOnDocClose(false)> _
11 Public Class ExampleDocClass
12 Inherits DocumentValidationScript
13
14 <IndexFieldVariableAttribute("Barcode")> _
15 Dim WithEvents Barcode As FieldScript
16
17 <IndexFieldVariableAttribute("Status")> _
18 Dim WithEvents Status As FieldScript
19
20 '--------------------------------------
21 Private Sub Barcode_FieldPostProcessing(ByVal sender As Object, ByVal e As Kofax.AscentCapture.NetScripting.PostFieldEventArgs) Handles Barcode.FieldPostProcessing
22 Try
23 If Len(Barcode.IndexField.Value) <> 6 Then
24 Throw New Kofax.AscentCapture.NetScripting.ValidationErrorException("Barcode nur 6-stellig!", Barcode.IndexField)
25 End If
26 Finally
27 End Try
28 End Sub
29
30 '--------------------------------------
31 Private Sub Barcode_FieldPreProcessing(ByVal sender As Object, ByVal e As Kofax.AscentCapture.NetScripting.PreFieldEventArgs) Handles Barcode.FieldPreProcessing
32 MsgBox("Barcode_FieldPreProcessing")
33 'This will skip the field
34 'e.SkipMode = PreFieldEventArgs.SkipModeEnum.SaveAndSkipField
35 End Sub
36
37 '--------------------------------------
38 Private Sub Status_FieldPostProcessing(ByVal sender As Object, ByVal e As Kofax.AscentCapture.NetScripting.PostFieldEventArgs) Handles Status.FieldPostProcessing
39 MsgBox(Status.IndexField.Value)
40 End Sub
41
42 '--------------------------------------
43 Private Sub Status_FieldPreProcessing(ByVal sender As Object, ByVal e As Kofax.AscentCapture.NetScripting.PreFieldEventArgs) Handles Status.FieldPreProcessing
44 MsgBox("Status_FieldPreProcessing")
45 'This will skip the field **********************
46 'e.SkipMode = PreFieldEventArgs.SkipModeEnum.SaveAndSkipField
47 End Sub
48
49 '--------------------------------------
50 Private Sub DocPostProcessing(ByVal sender As Object, ByVal e As Kofax.AscentCapture.NetScripting.PostDocumentEventArgs) Handles Me.DocumentPostProcessing
51 MsgBox("DocPostProsessing")
52 End Sub
53
54 '--------------------------------------
55 Private Sub DocPreProcessing(ByVal sender As Object, ByVal e As Kofax.AscentCapture.NetScripting.PreDocumentEventArgs) Handles Me.DocumentPreProcessing
56 MsgBox("DocPreProsessing")
57 'This will SaveAndSkip the document **********************
58 'e.SaveAndSkip = True
59 End Sub
60
61 '--------------------------------------
62 Private Sub Validation_BatchLoading(ByVal sender As Object, ByVal e As Kofax.AscentCapture.NetScripting.BatchEventArgs) Handles Me.BatchLoading
63 MsgBox("Validation_BatchLoading")
64 End Sub
65
66 '--------------------------------------
67 Private Sub Validation_BatchUnloading(ByVal sender As Object, ByVal e As Kofax.AscentCapture.NetScripting.BatchEventArgs) Handles Me.BatchUnloading
68 MsgBox("Validation_BatchUnloading")
69 End Sub
70
71 Sub New(ByVal bIsValidation As Boolean, ByVal strUserID As String, ByVal strLocaleName As String)
72 MyBase.New(bIsValidation, strUserID, strLocaleName)
73 End Sub
74
75 End Class
76End 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 (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
Blog author
Jürgen Voss
Do you still have questions? Just send me a message.
Do you still have questions? Just send me a message.