strange vb.net validation behaviour

strange vb.net validation behaviour

Postby ericvolkelbarno » Tue May 17, 2016 10:49 am

Scenario:

1. Created CurrentDocument variable as public shared in a different class to be used in the main vb class, and other classes

2. Assigned CurrentDocument in the DocumentPreProcessing method as CurrentDocument = e.Document.

3. In a FieldPreProcessing method (for a field name CaseID), if there is already a value (through ocr) makes a call to a different method located in a different class that performs a database lookup.

4. In the separate class method, if the lookup is successful, a value is assigned to another field (named CPName) as

CurrentDocument.IndexFields("CPName").Value = CP_FirstName

The name immediately appears in the appropriate field, but, when the cursor leaves the original field (CaseID) the name value disappears from the CPName field, and does not return. (The important point here is that the field assignment is being made by a method located in a secondary class, not the main batch class VB.NET class.)

5. If the CPName field assignment is moved to the actual Validation batch class script, the name doesn't appear until the cursor leaves the CaseID field, but at least the name stays and doesn’t disappear. I would think the name should appear as soon as the CaseID_FieldPreProcessing code has finished running, (which of course is before the cursor leaves the field).

Does anybody have any idea why the name disappears when the assignment occurs in a separate VB class?
or when the assignment is inside the main class, why the name doesn't appear until leaving the field that made the original db call?

Thank you very much,
ericvolkelbarno
Participant
 
Posts: 41
Joined: Wed Mar 07, 2007 6:28 am

Re: strange vb.net validation behaviour

Postby Warpfield » Wed Jun 01, 2016 7:20 am

It might be easier if you posted a simple Batch Class, with a Document Class that has a VB.NET Validation Script that reproduces this issue.

What version of Capture?
If they are going to hate you anyway for what you do, then you might as well put forth your best effort.
User avatar
Warpfield
Participant
 
Posts: 61
Joined: Tue Apr 10, 2007 8:11 am

Re: strange vb.net validation behaviour

Postby ericvolkelbarno » Wed Jun 01, 2016 7:24 am

Hello,

Thank you for the answer.

Version = 10.2.0.0.0.491

I might do as you suggest after finishing the batch class upon which I am working... some time considerations. This is really the first VB.NET bc I have created, so learning as I go.

Thank you again,

eric volkel-barno
ericvolkelbarno
Participant
 
Posts: 41
Joined: Wed Mar 07, 2007 6:28 am

Re: strange vb.net validation behaviour

Postby ericvolkelbarno » Mon Jun 06, 2016 11:52 am

Hello... figured out the problem. Following is from our documentation:

V. Problem with Assigning Values to Field in a Linked Class
1. When there was a linked class that would attempt to assign a value to a field of the current document object, the value would not be retained to the field.
2. The first assumption was that the failure was due to the class being linked was making the value assignment, rather than the assignment being accomplished in the base class.
3. In the linked class the assignment to the field in a current document was being made using the following code example:
CurrentDocument.IndexFields("BatchID").Value = "something"
4. While in the base class the assignment was made in the following code example:
BatchID.IndexField.Value = "something"
5. Through additional testing it was discovered that the failure to retain assignment had nothing to do with the class being linked, but rather because of the two different object models being used.
6. The supposition is that Kofax maintains a copy of the values held by all of the FieldScripts which is kept separate from the values of the CurrentDocument.IndexFields("Field").Value, and that the FieldScript values take precedence.
7. When the FieldScript object is passed to the linked class, any assignment that is made is retained when the focus leaves the field.
8. Originally the BatchID was created used the following methods:
Inside the base class:
Private Sub z_Ledgers_DocumentPreProcessing(ByVal sender As Object, ByVal e As Kofax.AscentCapture.NetScripting.PreDocumentEventArgs) Handles Me.DocumentPreProcessing

'------------Batch ID Creation---------------------------------
CheckBatchID()
End Sub
Private Sub CheckBatchID()

If String.IsNullOrWhiteSpace(BatchID.IndexField.Value) Then
BatchID.IndexField.Value = cm.CreateBatchID()
End If

End Sub
Inside linked class (cm as CommonMethods):
Private Function CreateBatchID() As String

Dim DateValue As Date
Dim strBatchName As String = CurrentBatch.Name
Dim iCount As Integer = CountString(strBatchName, "|")

'Remove extra pipe symbols if present
If iCount > 1 Then
Do Until iCount = 1
strBatchName = strBatchName.Remove(strBatchName.IndexOf("|"), 1)
iCount -= 1
Loop
End If

'Return date:
' 1) from batch name, or
' 2) if batch name is corrupted, from Kofax CurrentBatch.CreateTime value

If Date.TryParse(strBatchName.Substring(strBatchName.IndexOf("|") + 1).Trim, DateValue) Then
Return DateValue.ToString(DB2DateTimeFormat)
Else
Return CurrentBatch.CreateTime.ToString(DB2DateTimeFormat)
End If

End Function
9. This can be replaced with the following code:
Inside base class:
Private Sub z_Ledgers_DocumentPreProcessing(ByVal sender As Object, ByVal e As Kofax.AscentCapture.NetScripting.PreDocumentEventArgs) Handles Me.DocumentPreProcessing

'------------Batch ID Creation---------------------------------
cm.CheckBatchID(BatchID)

End Sub
Inside linked class:
Public Sub CheckBatchID(ByRef BatchID As FieldScript)

With BatchID.IndexField
If String.IsNullOrWhiteSpace(.Value) Then

Dim DateValue As Date
Dim strBatchName As String = CurrentBatch.Name
Dim iCount As Integer = CountString(strBatchName, "|")

'Remove extra pipe symbols if present
If iCount > 1 Then
Do Until iCount = 1
strBatchName = strBatchName.Remove(strBatchName.IndexOf("|"), 1)
iCount -= 1
Loop
End If

'BatchID date:
' 1) from batch name, or
' 2) if batch name is corrupted, from Kofax CurrentBatch.CreateTime value

If Date.TryParse(strBatchName.Substring(strBatchName.IndexOf("|") + 1).Trim, DateValue) Then
.Value = DateValue.ToString(DB2DateTimeFormat)
Else
.Value = CurrentBatch.CreateTime.ToString(DB2DateTimeFormat)
End If
End If
End With

End Sub
ericvolkelbarno
Participant
 
Posts: 41
Joined: Wed Mar 07, 2007 6:28 am


Return to Kofax Capture General Discussion

Who is online

Users browsing this forum: No registered users and 5 guests