Subject: URL to launch attachment of first document in a category
Sure – use an agent to find the attachment and print a redirection URL back to the browser. In LotusScript, a redirection URL that does not reflect the real URL back to the browser is enclosed in double square brackets. You will want to use the Path_Info CGI variable to get the relative URL of the agent; using Strleftback will allow you to get the URL of the database to use in building the redirection URL. This may not be the BEST way to code the agent, but it’ll work:
Dim s As New NotesSession
Dim context As NotesDocument
Set context = s.DocumentContext
Dim redirectPath As String
redirectPath = Strleftback(context.GetItemValue(“Path_Info”)(0), “/”)
Dim db As NotesDatabase
Set db = s.CurrentDatabase
Dim v As NotesView
Set v = db.GetView(“Reports”)
Dim nav As NotesViewNavigator
Set nav = v.CreateViewNavFromCategory(“Monthly Results”)
Dim targetDoc As NotesDocument
Set targetDoc = nav.GetFirstDocument
Dim attNames As Variant
attNames = Evaluate(|@AttachmentNames|, targetDoc)
Dim unid As String
unid = targetDoc.UniversalID
Print “[[” + redirectPath + “/Reports/” + unid + “/$File/” + attNames(0) + “]]”
You will want to add error checking, logging and so on to handle the cases where the category isn’t found, the first document doesn’t contain an attachment, and so forth. (Never trust the simple stuff posted here as examples as production code.)