Skip to main content

Reading and Writing Kofax Capture Custom Storage Strings


QAID # 17792 Published * INTERNAL ONLY * 

QAID # 17792 Published * INTERNAL ONLY *

Please do NOT provide the article number (QAID) and/or URL of this Knowledgebase article or its contents to external customers, as it is NOT Published and/or * INTERNAL ONLY *. 

Question / Problem:

Reading and Writing Kofax Capture Custom Storage Strings

Answer / Solution:

Relevant Version: KTM 4.0


It is often useful to access Kofax Capture Custom Storage Strings from within KTM. These storage strings allow you to easily store values at the document-level which can be read by all Kofax modules. This is of particular interest when you wish to preserve values which would otherwise be overwritten within KTM. In this article, sample code shows an example where the user wishes to retain the classification result before Document Review is run, where this would normally be lost if a document is reclassified.


Kofax Capture Custom Storage Strings are available through the "XValues" within KTM, which are available from within the XDoc when using document-level storage strings.

In order to write values to a Custom Storage String, it first needs to be created. The naming policy used for the string is important, as it is used to determine what kind of XValue is being created. For Custom Storage Strings, the prefix "AC_CSS_" is required, with the storage string name added at the end.

It is also important that the "MustSynchronise" property be set to true when creating these values — this tells KTM that the value should be written back to Kofax Capture, rather than being stored solely in the XDocument.

The solution given below shows creating and writing to Kofax Capture Custom Storage Strings while in KTM Server 1 (before Document Review), then reading and returning those values during KTM Server 2 (after Document Review).


This code is called from the Document_AfterExtract method, however Custom Storage Strings can be obtained from anywhere in the script, as long as you have access to the XDocument object (pXdoc).

Private Sub Document_AfterExtract(ByVal pXDoc As CASCADELib.CscXDocument)
Const KTM_SERVER_STEP_1 As Integer = 1
Const KTM_SERVER_STEP_2 As Integer = 2
Dim strClass1 As String, strConf1 As String
'check which instance of KTM Server we are in
   If Project.ScriptExecutionInstance = KTM_SERVER_STEP_1 Then
      If Not pXDoc.ClassificationResult Is Nothing Then
         'get final classification result
         strClass1 = CStr(Project.ClassByID(pXDoc.ClassificationResult.FinalClassId(0)).Name)
         strConf1 = CStr(pXDoc.ClassificationResult.Confidence(pXDoc.ClassificationResult.FinalClassId(0)))
         'store classification result and confidence in kofax capture custom storage strings
         pXDoc.XValues.Add("AC_CSS_Class1", strClass1, True)
         pXDoc.XValues.ItemByName("AC_CSS_Class1").MustSynchronize = True
         pXDoc.XValues.Add("AC_CSS_Conf1", strConf1, True)
         pXDoc.XValues.ItemByName("AC_CSS_Conf1").MustSynchronize = True
      End If
   ElseIf Project.ScriptExecutionInstance = KTM_SERVER_STEP_2 Then
      'we are now in KTM server 2, running after document review. Retrieve values
      strClass1 = pXDoc.XValues.ItemByName("AC_CSS_Class1").Value
      strConf1 = pXDoc.XValues.ItemByName("AC_CSS_Conf1").Value
      MsgBox "Original Classification: " & strClass1 & " Confidence: " & strConf1
   End If
End Sub

Applies To: 

Product Version Category
AXPRO 4.0 Script
  • Was this article helpful?