Having problems referencing File Attachments during WebQuerySave Agent

Hi

I’m fairly new to both R6 & web stuff, & I’m trying desperately to get hold of attached files during the WebQuerySave Agent of a web document.

I have the following, which works:

Dim Session As NotesSession, docFile As NotesDocument, fileAtt As NotesEmbeddedObject

Sub Initialize

Set Session = New NotesSession

Set docFile = Session.DocumentContext

If Not(docFile.HasEmbedded) Then

	docFile.SaveOptions = "0"

	Print "<b>Error:</b> There was no file attached.<br>"

	Print "<a href = ""javascript:history.go(-1)"">Try again</a>, or " & _

	"<a href = ""/dev/FileExchange.nsf/restricted/home.html?OpenDocument"">Return to Main Page</a>"

	Exit Sub

End If

However, I need to add this:

docFile.FileName = fileAtt.Name

docFile.FileSize = fileAtt.FileSize

… which means first I need to get hold of fileAtt, but none of this works:

Forall att In docFile.EmbeddedObjects

	Print "Found: " & att.Name & "..."

End Forall

Print "There are " & Cstr(Ubound(docFile.EmbeddedObjects)) & " attachments..."

Set fileAtt = docFile.EmbeddedObjects(0)

Each time I add any of the above, the Agent fails, & the browser gets ‘Form Processed’.

Can anyone see where I’m going wrong?

Thanks,

Subject: Having problems referencing File Attachments during WebQuerySave Agent

I’ve now managed to get the Remote Debugger working (what a fantastic feature, by the way!), & have seen that although docFile.HasEmbedded is true, docFile.EmbeddedObjects appears to be an empty array, so UBound(docFile.EmbeddedObjects) raises a type mismatch!

How can I get hold of the attachment - do they need to be in a Rich Text field?

Subject: RE: Having problems referencing File Attachments during WebQuerySave Agent

Hi Notes Gurus, Even I am facing the same problem.

I am calling an agent on Web Querysave and trying to create HTML anchor links to the attachments in the $File. Then reloading the form so that the user can click on the link to open the elements.

The problem is same, its giving the hasEmbedded property to True and then giving type mismatch to doc.EmbeddedObjects.

I learnt from posting in this forum that EmbeddedObjects for notesdocument doesnot works for Attachment.

I am using R6.0.2 server.

I am aware of traversing through the $Files in R5 and then removing the item each time. But again this doesnot works for R6.

Can someone please please guide me how to loop through the $File references for a document.

Many thanks in advance.

Regards

Tamajit

Subject: RE: Having problems referencing File Attachments during WebQuerySave Agent

Hi,

I had the same problem, but I found a workaround, using @AttachmentNames.

In the WebQuerySave (Formula) use the following code :


FIELD AttList := @AttachmentNames;

@Command([ToolsRunMacro]; “YourAgent”);

AttList := @DeleteField


Then in your agent context document you can access to the list :


Sub Initialize

Dim Session As New NotesSession

Dim Db As NotesDatabase

Dim Context As NotesDocument

Set Session = New NotesSession

Set Db = Session.CurrentDatabase

Set Context = Session.DocumentContext

Dim flist As Variant

flist = Context.GetItemValue(“AttList”)

If (flist(0)=“”) Then

’ no attachment

Else

’ loop into names

Forall fname In flist

Print “filename=” & fname

End Forall

End If

End Sub


Eric.