Web Link to Attachment

I am trying to get a page to redirect to the URL of the attachment on the first record of a view.

I have been through the forum and so far I have done the following:

Create a Page with Java script to redirect to a URL:

location.replace(“”)

In the Compute Value I have

http://www.mysite.com/” + @WebDbName + “/view/” + @Text(@DocumentUniqueID) + “/$file/” + @AttachmentNames

This will work if I hard code the Document ID.

This will do the same as the computed text

document.location.href=“http://www.mysite.com/db/view/$first?OpenDocument

I would like it to get the doc ID of the first doc then set that to a variable to put in the above text.

I also played with $first?OpenDocument, but I don’t want the record to open.

I can’t figure out how to set the variable for the first document id and place it in the computed text or javascript.

Thanks in advance.

Subject: Web Link to Attachment

I would add a hidden column at the front of your view, sort it ascending, and use @DocNumber as the value. You should be able to use /view/1/$file/ to reference it. I use something like this to create a permanent link to the newest document in a particular database.

On a side note, I would use a meta tag instead of javascript for the redirect, just in case someone has js disabled. Also @AttachmentNames can be a text list, so you might want to use @Subset on it, if its possible for it to have more than one attachment.

Edit: This will not work if the view is categorized.

Subject: Web Link to Attachment

I may be missing something, but I have added that Doc Number field and now I can open the document with a View/1/, but now in the page that does the redirect I can’t get the @attachmentnames to compute for the rest of the html. I have tried many different ways.

What I am looking to do is have a button on the web page that is coded to open a link to the file. The file name will always be different.

Thanks for you help so far.

Subject: RE: Web Link to Attachment

Sorry, I missed that. @AttachmentNames returns the names of the attachments in the current document. If you are putting this formula on a page, then it will probably be empty, since the page won’t have attachments.

I think it makes the most sense to add another column to your view that lists the attachment name, and retrieve it with a @dblookup.