Manage Learn to apply best practices and optimize your operations.

Rt Field, Attachment And Picture

Nirvana -
We all know that if we web-edit a document with RT fields(displayed as Java
applet on browser), we lose all the pictures that might be available in RT
fields. This problem bugged me for atleast 3 days and this is how we managed to
have a round about way of acheiving the same of preserving the pcitures in the

We have a computed for display field say Field1, the formula for which is

@If(@Attachments=2; "[&LTimg src=\"" + @Text(@DocumentUniqueID) + "/$file/" +
@Subset(@AttachmentNames; -1) + "\" border=0 >]" ; "")

Here my document needs to have 2 pictures and hence two attachemnts.

I attach the pictures using Upload controls.

But here I face a problem that the files I attach get appended to the text,
links that are already existing in RT field(Java Applet), say FIELD2 . I want
the the RT field as java applet so that he has more editing options .... like
including links, having different styles of texts in the field. I would not
have had the problem if I had the RT field as the HTML field.

So, I include another RT field as Java applet, say FIELD3 and hide the field.
But this time, when I attach the files, I see attachment entries in both the
fields and if I delete the attachment entires in either of the fields, I lose
the $file field from the document.

To acheive this I create a temporary document with a RT field, move the
contents of the RT field to the RT field in the temporary document delete the
contents of the FIELD2 in the original document and then copy the contents of
the RT field in the temporary document to FIELD3. That way I dont lose the
$File field in the document and also I can avoid seeing the attachemnts in the
documents. The code for this to and fro movement of attachments ;-) is given
Dim osess As Notessession
Dim ocurdb As notesdatabase
Dim oview As Notesview
Dim odoc As Notesdocument, tempdoc As Notesdocument
Dim rtitem As notesrichtextitem
Dim object1 As notesembeddedobject
Dim rtitem2 As notesrichtextitem, rtitem3 As notesrichtextitem
Dim names As String, flag As Integer

Set osess = New notessession
Set ocurdb = osess.currentdatabase
Set oview = ocurdb.getview( "Tview" )

Set odoc = oview.getfirstdocument

While Not(odoc Is Nothing)
Set tempdoc = New Notesdocument( ocurdb )
tempdoc.form = "displayform"

Set rtitem2 = tempdoc.CreateRichTextItem( "S_Text_1" )
Set rtitem3 = odoc.getfirstitem( "testRT" )
Set rtitem = odoc.getfirstitem( "S_Text_1" )

Call rtitem2.appendrtitem( rtitem )

If ( rtitem.Type = RICHTEXT ) Then
Forall o In rtitem.EmbeddedObjects

If ( o.Type = EMBED_ATTACHMENT ) Then

Call o.Remove

End If
End Forall
End If

Call rtitem3.appendrtitem( rtitem2 )
odoc.temptext = "0"
odoc.reload = 1
Call odoc.Save( False, True )
Set odoc = oview.getnextdocument( odoc )

Call tempdoc.remove( True)

Dig Deeper on Domino Resources - Part 7

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.




  • iSeries tutorials's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...