Autor Thema: Tricks um Ursache eines nicht-funktionierenden Compute-with-form herauszufinden  (Gelesen 3471 mal)

Marinero Atlántico

  • Gast
... gibt es nicht.  ???
Oder?

Gruß Axel

Glombi

  • Gast
Das wäre in der Tat ein wünschenswertes Feature. Leider ist mir kein Weg bekannt ausser dem mühsamen manuellen Prüfen aller Felder.

Andreas

Glombi

  • Gast
Was man auch wissen muss:

In most cases, the ComputeWithForm method (of the NotesDocument class) can be used to refresh documents.  This method is actually designed to trigger a field's Default Value, Input Translation and Input Validation formulas, but it also does trigger Computed formulas as well.

The ComputeWithForm method is not suitable for refreshing forms which have a Computed field which refers to itself.  This is because the ComputeWithForm method recalculates the document twice, which would cause undesirable results in such a field formula.

For example, consider a form with a Computed Numeric field called Count, and the formula for this field is "Count+1".  If the Count field had a value of 1 before the ComputeWithForm method was called, then afterwards the Count field would have a resulting value of 3.

For cases where a field's formula references itself, there are two ways to workaround this limitation:

Refresh the document using either @Command[ToolsRefreshSelectedDocs] or @Command[ToolsRefreshAllDocs].

Perform the formula calculation for the field in the LotusScript agent itself

Glombi

  • Gast
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

Marinero Atlántico

  • Gast
Aus meiner Erfahrung liegt es in 99% aller an falschen Datentypen.
Die neu über script gesetzten sind aber alle ok (setze mit doc.replaceItemValue("fName, value)).
Wenn da aber irgendwo innendrin in der Maske etwas nicht koscher ist, kann es sehr, sehr zeitaufwendig werden. 

 

Impressum Atnotes.de  -  Powered by Syslords Solutions  -  Datenschutz