Attachments - Code Included

I have a form that allows a user to attach a document over the web using a file upload control.

The attachment is saved and then I am using an agent to pick up and display all of the data entered (like a search engine).

I have a three views set up, each are sorted differently. Each of these views have the 5th column value set to Attachment Names.

I have four search options, Date, Region, Topic and Keyword.

The Date and Keyword options use the AllTopics view. The Region option uses a ByRegion view and the Topic option uses a Topics view.

When I search by Region or Keyword, the attachment is picked up and displayed. When I search by Date or Topic, then the attachment is empty.

Even stranger…the Date and Keyword search use the same view, but only the keyword search returns the attachment!!!

Code:

Set db=session.currentdatabase

Set view = db.getView(sView)

If sSearchType = “” Then

Set doc = view.GetFirstDocument

sSeminarDate = doc.ColumnValues(0)

sMonth = doc.Month(0)

sDay = doc.Day(0)

sYear = doc.Year(0)

sHdg1 = sMonth & " " & sDay & ", " & sYear

Elseif sSearchType = “Date” Then

Set co = view.GetAllDocumentsByKey(sKey)

Set doc = co.GetFirstDocument

Elseif sSearchType = “Topic” Then

Set vc = view.GetAllEntriesByKey(sKey)

Set entry = vc.GetFirstEntry

Set doc = entry.Document

Elseif sSearchType = “Region” Then

Set view = db.getView(sView)

Set doc = view.GetFirstDocument

Else

Set view = db.getView(sView)

Set doc = view.GetFirstDocument

End If

.

.

sAttachment = doc.ColumnValues(5)

I posted this question yesterday and someone suggested using the getembeddedobject option, but I think I need to know the name of the attachment.

I need to find out the attachment name, which I then display in my agent for viewing:

sAttachURL = “/intranet/MicroSem.nsf/AllTopics/” & sID & “/$File/” & sAttachment & “?OpenElement”

I can’t understand why it is working in some cases and not others!

Any ideas or suggestions would be greatly appreciated. Sorry for the second post, but my original post was lacking the fact that it is partially working…

Thanks in advance.

Subject: @AttachmentNames - would this help?

Subject: RE: @AttachmentNames - would this help?

@AttachmentNames is formula language. As this is a lotus agent, I don’t think that it would be a suitable solution.

Thanks for the idea though!

Subject: @AttachmentNames - will work.

A computed field with @AttachmentNames would give the name and then with script, you get the name.

Subject: RE: @AttachmentNames - will work.

Unfortunately, I don’t have a form to contain the field - an agent is generating my ‘form’.

Subject: RE: @AttachmentNames - will work.

Might try evaluating @AttachmentNames - see here.dgg

Subject: Attachments - Code Included

Howdy! :wink:

Since it is “partially working”, then my guess that the problem lies in the “sAttachment” result.

Are there any spaces in the attachment name? Any slashes? Accents? Anything the browser might not like? If so, then you can clean it up in the appropriate column in the “AllTopics” view.

Do any of the documents have multiple attachments? If so, then only show the 1st attachment in the view.

Also, I don’t think “GetEmbeddedObject” will help here. You seem to have a good handle on what you need.

HTH!

Steve in Montreal =8)

“My grandmother started walking 5 miles a day when she turned 60. She’s now 97, and we have no idea where the hell she is.”

Subject: RE: Attachments - Code Included

The attachment names do not contain any special characters or spaces. For example, one attachment is MSTutorial.doc

Also, there is only one attachment per document.

In any event, if there was a problem with the name, wouldn’t it be safe to say that none of the search results would contain the attachment?

Thanks for your response. I’ll keep at it.

Subject: RE: Attachments - Code Included

Howdy! :wink:

OK… so, when does it not work? Is it the search that’s not working, or is the attachment not opening? In the debugger, where are you getting the problem?

If the problem is in the search results, then maybe we can take a look at that part for ya’. ~8P

Good luck!

Steve in Montreal

“Wherever you go, there you are.”

Subject: RE: Attachments - Code Included

When this code is executed:.

.

.

sTopic = doc.Topic(0)

sRegion = doc.Region(0)

sStatus = doc.Type(0)

sAttachment = doc.ColumnValues(5)

sAttachment is empty.

As I said though, it does work for the Region and Keyword search, just not for the Date and Topic search.

Thanks!