Domino 9 und frühere Versionen > Entwicklung

Modify a RTF field . Refresh it - Strange behaviour !

(1/4) > >>

Toma Bogdan:
I want to have a rich text field to add comments to while protecting
what is already in there without changing user access control or
redesigning the database.

It works like this (with 3 fields):
1) Computed rich text field, CommentsDisplay with formula Comments
2) Rich text field, Comments, which does not show up on form at all --
it contains previous comments
3) Editable rich text field, NewComments -- where th user add his
input and attach docs

and the code in the PostSave form event :

--- Code: ---Sub Postsave(Source As Notesuidocument)
Dim mainDoc As NotesDocument
Set mainDoc=Source.Document
Call mainDoc.RemoveItem( "CommentsDisplay" )
Dim rtitemA As Variant
Dim rtitemB As Variant
Set rtitemA = mainDoc.GetFirstItem( "Comments" )
Set rtitemB = mainDoc.GetFirstItem( "NewComments" )
Call rtitemA.AppendRTItem( rtitemB )
Call rtitemB.Remove
Call mainDoc.Save(False, True )
End Sub

--- Ende Code ---

but it is a strange behaviour:

step 1: I create a new doc
step 2: I put the string "1" in the NewComments field
step 3: I save the doc
step 4: when I open the doc :
Comments field "1"
CommentsDisplay field nothing
NewComments field nothing
step 5: I put the string "2" in the NewComments field
step 6: I save the doc
step 7: when I open the doc :
Comments field "12"
CommentsDisplay field "1"
NewComments field nothing
step 8: I put the string "3" in the NewComments field
step 9: I save the doc
step 10: when I open the doc :
Comments field "123"
CommentsDisplay field "12"
NewComments field nothing


Why the field CommentsDisplay which had a computed formula doesn't refresh on doc open ?!? (it is with a step backward than Comments field ...) ?

Rob Green:
jez.. :o :o

just a try:
use the field comments and newcomments
make comments > computed => on field comments itself

then your script and all seems ok now...


And what about the commentsdisplay field?
...i´m not too sure with computed RichText field types, but take a look at the field values in the read mode ... the rt field "comments" is twice there.."comments" and "comments"! Containing the old values in "one" field and the newest values in the "second" field. So, this could be the explanation that commentsdisplay is always one behind.

Toma Bogdan:
The Comments field keesp the last inputs of the users to prevent them to modify something ! I display this information into CommentsDisplay field and after they write something in the NewComments field I add this field to the Comments field !

Here is the sample Notes database (zipped) !

Rob Green:
ok, i think i understood it .. ;)

but, once again: the problem is - im very sure about - , that the commentsdisplay field is related to the comments field, which exists twice after the first save.

1. creation of doc
entering AA
2. saving first time
3. read mode: 2 (!!!) fields "comments" in the field list>
first  "comments": AA
second "comments" : empty
4. edit doc
entering "BB"
5. saving
6. again two comments fields
first "AABB"
second "BB"
....

see what i mean?
Commentsdisplay always shows the right field, but which one of both ?  ;D

Toma Bogdan:
I suppose that you saw the sample ! I belive that it is a simple solution ... but what is that solution  ???

Regards

Navigation

[0] Themen-Index

[#] Nächste Seite

Zur normalen Ansicht wechseln