Is there any way to replicate this via Lotusscript? I believe the answer is no if for the NotesUIDocument.
I know I can do it via NotesRichTextItem and Embeddedobjects however this doesn’t work via the NotesUIDocument. I can set it up via an agent or an action that will add the file to the field.
You are correct that in LotusScript we have " EmbedObject" method to play with attachments.
However it has following limitation:
“In an open document in edit mode (the NotesDocument via NotesUIDocument.Document), changes made to rich text will not appear on screen immediately as they would with fields of other types. There is no method to cause this update to occur. You must close and reopen the document to see changes.”
Probably, you can use LotusScript to auto close and auto reopen the document after the attachment is attached.
create form called “fAttachFile”
in QueryOpen : @Command([EditGotoField];@Environment(“fieldToAttachTo”)); @Command( [EditInsertFileAttachment] ;@Environment(“fileToAttach”); “1”;“1”)
use a SubForm with QueryOpen continue = false so the form never opens
to attach the file from LotusScript…
Sub attachFileToField(fileName As String, fieldName As String)
Dim ws As New NotesUIWorkspace
Dim session As New NotesSession
Dim tempDoc As NotesDocument
Set tempDoc = session.CurrentDatabase.CreateDocument
tempDoc.form = “fAttachFile”
On Error Resume Next ’ get user defined error if this isn’t here
ws.EditDocument false,tempDoc,True,False,true ’ @Formula in queryOpen attaches the file