get the attachmentname from 1 out of 2 rich text fields

501 Views Asked by At

I have a form with 2 rich text fields. They both store pictures. I have 1 text field to store the name of the second rich text field. For this I'm using : @Subset(@AttachmentNames;1) but the problem is that in this way I don't have control from which rich text field the attachmentname is comming. Any idea ?

2

There are 2 best solutions below

0
On

Unfortunately there is no way to do this with Formula. In LotusScript you can do something like:

Dim ws as New NotesUIWorkspace
Dim uidoc as NotesUIDocument
Dim doc as NotesDocument
Dim body1 as NotesRichtextItem
Dim body2 as NotesRichtextItem

Set uidoc = ws.CurrentDocument
Set doc = uidoc.Document
Set body1 = doc.GetFirstItem( "NameOfFirstField" )
Set body2 = doc.GetFirstItem( "NameOfFirstField" )

If Not Isempty(body1.EmbeddedObjects) Then    
  Forall o In rtitem.EmbeddedObjects      
    If ( o.Type = EMBED_ATTACHMENT ) Then        
      'Found attachment: add name to list
      'do something with o.Source, this is the name of the attachment
    End If
  End Forall
End If

Take care: The attachments in LotusScript are only current after a save of the document...

0
On

You can use Lotusscript. RichTextItem can contain an EmbeddedObject, which has property Source. For attachments, this contains the file name.

Quote from help file:

Dim doc As NotesDocument
Dim rtitem As Variant
Dim object As NotesEmbeddedObject
Dim sourceName As String    
'...set value of doc...
Set rtitem = doc.GetFirstItem( "Body" )
If ( rtitem.Type = RICHTEXT ) Then
  Set object = rtitem.GetEmbeddedObject( "City picture" )
  sourceName = object.Source
End If