Hello there,
I have a XPage with a standard view control on it. I am converting an old client app to web and in the client version, as soon as the user clicked the document in the view, it opened the first attachment on the document
Is there a way where i could replicate this functionality in an Xpage view control?
So when the user open the view, one of the columns is a hyperlink, which will open the PDF attached to the document they clicked?
Appreciate any suggestions/help.
F1H
Subject: Open Attachment from View
If your XPage is being viewed on the web you can append / insert a column. You can then add a link to that column - see Paul Hannan’s article on the XPages blog: サッカー ユニフォーム 安い – xpagesblog.com | 安いジャージを買う。 21.99 という安いジャージ。 ファンに最高のコレクションを提供します。 安心してお買い物をしてください。
You just need to ensure your ViewPanel has a var defined (go to the All Properties box of the View Panel or type into the source pane) - this allows you to get a handle on the row. You also need to ensure the column is bound to an actual column (otherwise you’ll get an error) and that it has value=“” to suppress the column value from appearing. You can then add a link to the column (“xp:link</xp:link>” or drag and drop and m it to the column either in the outline or the source pane).
The link url can then be computed to “/0/” + myVar.getDocumen().getUniversalID() + “/$FILE/” + @Subset(@AttachmentNames(),1). This should get a handle on the first attachment name and use the default view to launch it. Because this is a classic web URL the default view needs to be accessible to the web.
Note, from what I’ve been told, this will not work for XPages in Notes Client because the classic web URL does not work. I believe you can call a function in the XPages code installed with the client (not sure which, I havn’t looked) or a link calculating the whole URL may work. You’ll need to do some investigation if you need that. I’m sure code to identify if the user is in the Notes Client is readily available, if you need to do different things based on client or web.
Subject: Compute URL?
Hi Paul,
Thanks for that, so I have added another column onto the view and selected a column from the view. I have put a mask on the value of “View Doc”…my only question is :
I am assuming that myVar is a viewEntry …but how would i get the document clicked? If you can give me a little code to do this, i would appreciate it
Thanks
F1H
Subject: Re: Compute URL?
myVar is the value you define for var in your viewPanel, so you’re always getting the relevant NotesXSPViewEntry object. getDocument() gets the back-end NotesDocument and getUniversalID() gets its UNID to include in your computed URL.
So your viewPanel will be comething like this in the source panel:
<xp:viewPanel id=“viewPanel1” rows=“30” var=“myVar”>
Now that I’ve looked into it further, the problem is @AttachmentNames - it nly works on the currentDocument object, so expects a document to be open. I’ve got a solution which may seem a bit complex (it requires you to use a repeat control in your view column) but actually is fairly straightforward. I’ll post it on the notes and domino app dev wiki and add a link here.
The solution will only work though if you’re wanting to open the first attachment in a NotesRichTextItem / number of NotesRichTextItems. This is because the getEmbeddedObjects() method of NotesDocument cannot get a handle on attachments. I’m assuming that’s not a problem for you.
Subject: Here’s the article showing two ways
Here’s the link to the article I’ve added to the Lotus Domino App Dev wiki, called Launching First Attachment from a View.
http://www-10.lotus.com/ldd/ddwiki.nsf/dx/Launching_First_Attachment_From_a_View_in_XPages
Subject: Thanks!
Paul,
Thank you very much for your help on this - really appreciate it.
It works a treat! 
F1H
Subject: An alternative option
Another option is to add a column to your view with the following formula:
“./0/” + @Text(@DocumentUniqueID) + “/$FILE/” + @Subset(@AttachmentNames;1)
You can then use the column value as your link.
Subject: Open attachment from xpage view
I have gotten the launch attachment to work on the web - thanks for the info.
I was wondering if there is a way to get this to work in the Notes Client.
Thanks,
Chris