David Crewe Ltd


Independent Kofax KC³ Consultant

How to Create Validation Scripts

Create a Validation script by right-clicking on a document class and selecting Document Validation Script.

Select VB.NET as Scripting Language and Create.

NB. It is best to define all your Index Fields first, and create the script afterwards, as a template will be created with all the relevant fields included. If you later add/rename an Index Field used in the script, you will need to manually edit the script to include or remove new or deleted fields.



A template script will be created with each defined Index Field included:



You can create code for each Index Field and add script to this directly, and you can also add any required script functions into the template as shown below.

These can then be called from anywhere else in the validation script.



Select the Index Field you want to use the function against from the top left drop down, and FieldPostProcessing from the top right drop down.

Add the following line to the function which is created for that Index Field:

  Customer_Reference.IndexField.Value = RemoveMultipleSpaces(Customer_Reference.IndexField.Value)

NB. The above is for an Index Field called Customer_Reference and a function called RemoveMultipleSpaces. Replace these with the actual Index Field name, and function required.



Save the project, and select Build > Rebuild Solution from the menu bar.

Close the editor.

Re-publish the batch class and test the script by processing a batch through to validation. In the above example any multiple spaces would be removed and only single spaces would be left. So the original OCR/ICR value ‘123   High  Street   London’ would be replaced with ‘123 High Street London’ as the field is exited in validation.

It is possible to use more than one script for the same Index Field in this way. For example if you use the RemoveMultipleSpaces script, and also the UpperCase script, you could call them both by adding the following to the FieldPostProcessing function:

  Customer_Reference.IndexField.Value = RemoveMultipleSpaces(Customer_Reference.IndexField.Value)

  Customer_Reference.IndexField.Value = UpperCase(Customer_Reference.IndexField.Value)

This will apply both methods to the Index Field data.