Finalize function

The following method called in Validation updates all match remarks in the column Match Remark (global column ID: 16000) if the table model contains it. Additionally, if the generation of training data is configured for a locator, this data is generated if all rows can be matched. Where matched means that the MatchPositionIndex field for all rows contains a value that is not -1, and that the columns used for matching (Quantity, UnitPrice, ExtendedPrice) contain data with coordinates. Then a training document is created that is used in addition to the documents the server creates.

Existing data in the Order Number column and in the MatchPositionIndex column are no longer updated.

Columns that are configured to be filled by additional data from the purchase order database are no longer updated by this function. This is only possible in the Match function.

Public Function Finalize (_
    ByVal pXDoc As CASCADELib.CscXDocument, _
    ByVal sTableFieldName As String, _
    ByVal sVendorID As String _
    ) As Long
pXDoc

XDocument object that is finalized, matched and perhaps for online learning.

sTableFieldName

Name of the table field that contains the line items to finalize.

sVendorID

Vendor ID used for matching the line items, this value is not mandatory and can be filled with an empty string.

Return: Long

Returns the number of the line items that are matched, what is equivalent to the number of rows that have a value in the column MatchPositionIndex that is not empty and not -1. If the number of matched rows equals the number of rows in the table is completely matched.

Important All rows need to have a valid purchase order number to ensure that the matching of all rows can be performed. This can be the same for all rows or in case of multiple purchase order numbers different ones.

You can use the following code snippet in your script code to call the Finalize function:

' Add a reference to "Kofax Cascade Line Item Matching Locator" library to your script!
Private Function Finalize(pXDoc As CASCADELib.CscXDocument, sClassName As String, sLocatorName As String, sTableFieldName As String, sVendorID As String) As Long
   Dim pClass As CASCADELib.CscClass
   Dim pLocatorDef As CASCADELib.CscLocatorDef

   ' get the locator definition to use for the finalizing
   Set pClass = Project.ClassByName(sClassName)
   Set pLocatorDef = pClass.Locators.ItemByName(sLocatorName)

   ' convert it to the LineItemMatchingLocator interface to call the match method
   Dim oIExtMethod As CASCADELib.ICscExtractionMethod
   Set oIExtMethod = pLocatorDef.LocatorMethod
   Dim oILIMLoc As CscLineItemMatchingLocLib.CscLineItemMatchingLocator
   Set oILIMLoc = oIExtMethod

   Finalize = oILIMLoc.Finalize(pXDoc, sTableFieldName, sVendorID)

End Function