Duplicate rich text fields (rtf) in R6

In general, a Notes document may contain more than one item with the same name. In practice, this is almost universally avoided, except for rich-text fields.

In R6.5.3, if a script attaches more files to a rich-text-item during WebQuerySave(), Domino actually creates a second item of the same name, and the mods end up there. (This is true both for brand-new documents and pre-existing documents.)

The document still contains two items with the same name after the web save completes. If you open the document, the rich-text items display together in a single field, on the Web and on the Notes Client.

What if the user then re-opens that document for editing on the Web, and makes no changes to rich-text, and saves? The document still has two items by that name when the web save completes.

What if the user then opens that doc in the Notes Client, makes no changes to rich-text fields, and saves? The multiple items merge into a single item during the Client save. (There may be exceptions, I do not know, I would imagine there are size limitations.)

(You can verify all these statements with a web app and your Properties box.)

IWBNI multiple rtfs automatically merge during a Web save, as they do during a Client save.

As things stand, when you code for rtf data in documents created on the web, you must assume multiple items of the same name may exist, and you must assume that your changes may end up in multiple rtf’s of the same name.

What if you then open the doc on the Web and remove attachments during a WebQuerySave() with code like this? :

Set EmObject=doc.GetAttachment(filename)

If Not EmObject Is Nothing Then

Call EmObject.Remove

End If

Afterward, the rich-text field may well display the wrong files, by including some of the deleted, and lacking some that were not deleted! The $File items will be correct, but the RTFs may be wrong. If you then open this document in the Notes Client, and double-click the attachment that you deleted but still displays, you get the dialog “Note Item Not Found” “OK”. This seems to be a sort of bug.

One more piece of advice: if you are deleting attachments and re-attaching them elsewhere in the same document, you may find yourself making a file with the “ATTnnnn” filenames. This name is substituted by Domino when it considers your file attachment to be a duplicate of an existing one. However, I find this does not happen if the $FILE item is item.Remove()'d and the RTI in which the file is embedded is also item.Remove()'d. Ater that, even without doing a Save(), embedding attachments works fine.