Und aus der alten KBASE (bezog sich auf R4, gilt aber wohl im wesentlichen auch für R6 vermute ich mal):
Error: "Field in Note Has Wrong Datatype" Using ComputeWithForm Method
Problem:
When you use the ComputeWithForm method (of the NotesDocument class) on a document, one of the following errors occurs:
"Notes Error: Field in note has wrong datatype"
"Notes Error: Cannot convert text to a number"
One form that can cause these errors is the Person form in the Notes 4.5 Public Name and Address Book (N&A Book).
Solution:
The error "Field in note has wrong datatype" occurs when a date field has been populated with a value which is not a valid date. If the field is being populated via a formula in the form itself, be sure that the formula evaluates to a proper date and not a number. For example: A computed field with the formula @Year(@Now) returns a year only, which is a number and not a complete date. If the field has a computed or default value which is set to the field itself, then the workaround is to set the field to a date value prior to calling the ComputeWithForm method. For example:
This agent sets the DateTimeValue property of the NotesItem object prior to calling ComputeWithForm.
Sub Initialize
Dim Work As New Notesuiworkspace
Dim Doc As Notesdocument
Dim Item As Notesitem
Dim DateTime As New Notesdatetime("")
Set doc=work.currentdocument.document
Set item=doc.getfirstitem("StartDate")
Set item.datetimevalue=datetime
Call doc.computewithform(True, True)
Call doc.save(True, True)
End Sub
The error "Cannot convert text to a number" occurs when a numeric field has been populated with text.
If the field is being populated via a formula in the form itself, be sure that the formula evaluates to a numerical value rather than a text value. For example, the following computed or default value formula would cause this issue: @If(@IsNewDoc; "None"; fieldname). In this case, the formula should be re-written, replacing "None" with "" or 0.
If the field has a computed or default value which is set to the field itself, then the workaround is to set the field to a numerical value prior to calling the ComputeWithForm method. For example:
This agent sets the field Count to zero prior to calling the ComputeWithForm method:
Sub Initialize
Dim Work As New Notesuiworkspace
Dim Doc As Notesdocument
Set doc=work.currentdocument.document
doc.count=0
Call doc.computewithform(1, 1)
Call doc.save(True, True)
End Sub
Supporting Information:
One form that can cause this error is the Person form in the Public Name and Address Book (N&A Book). The PasswordChangeDate field in the Person form is a date field with a computed value and a default value that refer to the field itself.
To address this issue, set the value for the date field to a specific date value. The following code sample uses the PasswordChangeDate field of the Person form and sets the field to the current date and time:
Sub Initialize
Dim Work As New Notesuiworkspace
Dim Doc As Notesdocument
Dim Item As Notesitem
Dim DateTime As New Notesdatetime("")
Set doc=work.currentdocument.document
Set item=doc.getfirstitem("PasswordChangedate")
Call datetime.setnow
Set item.datetimevalue=datetime
Call doc.computewithform(1, 1)
End Sub
Andreas