LotusScript Remove method removes attachment from Rich Text field but not from document

Technote (FAQ)


Question

The LotusScript Remove method (of the NotesEmbeddedObject class) does not remove attachments as expected in Lotus Notes®. Under certain conditions, the attachment is removed from the Rich Text field but not from the document. The attachment appears at the bottom of the document below a line, similar to the way attachments display on a browser.

This issue occurs in cases in which the document has more than one Rich Text field (in addition to the one containing the attachment) which are touched by the LotusScript code.

For example, if a document had a Rich Text field, "Body", and a second Rich Text field, "wBody", (similar to the "Memo form" in the mail template), either of the two agents below would cause this issue to occur:

Example 1:
Using a Forall statement to loop through the NotesDocumentObjects Items property:

Forall i In doc.items

    If i.type=RICHTEXT Then
      If i.name="Body" Then
        Forall o In i.embeddedobjects
          If o.type=EMBED_ATTACHMENT Then
            Call o.remove
          End If
        End Forall
      End If
    End If
End Forall
Call doc.save(True, True)

Example 2:
Using the GetFirstItem method to touch an additional Rich Text field:

Set rt1=doc.getfirstitem("Body")
Set rt2=doc.getfirstitem("wBody")
    Forall o In rt1.embeddedobjects
      If o.type=EMBED_ATTACHMENT Then
        Call o.remove
      End If
    End Forall
    Call doc.save(True, True)

Answer

This issue was reported to Quality Engineering as SPR# TKIE5Y89NS and was indirectly fixed in Notes 7.0, 6.5.4, and 6.0.5 releases


Workaround:
Use the GetFirstItem method to get a handle to the Rich Text field containing the attachment. Remove the attachment and save the document. Once the document is saved, the Forall Items and GetFirstItem logic can be used to touch and/or update other Rich Text fields.

Example:

    Set rt1=doc.getfirstitem("Body")   'Get handle to specific Body field
      Forall o In rt1.embeddedobjects
        If o.type=EMBED_ATTACHMENT Then
          Call o.remove
        End If
      End Forall
      Call doc.save(True, True)   'Save doc after removing object

      'Now can use GetFirstItem or Forall i in doc.items....
      Set rt2=doc.getfirstitem("wBody")
      ...
      Forall i in doc.items
      ...
      End Forall
       ...
      Call doc.save(True, True)

Related information

Remove Method (of NotesEmbeddedObject Class) Does Not R
How to Get a Handle to an Attachment that Is Part of th


Rate this page:

(0 users)Average rating

Document information


More support for:

Lotus End of Support Products
Lotus Notes

Software version:

6.0, 6.5

Operating system(s):

Linux, Windows

Reference #:

1166667

Modified date:

2004-09-09

Translate my page

Machine Translation

Content navigation