I’m trying to display a link to a document as an entry in a view column. The link would take the user to a document in another database when they click on it. Is this possible?
Subject: Displaying Links in View Columns
In the Notes client, no. Doclinks are only supported in rich text fields, and you can’t use a rich text field in a view column.
If this is a web app, yes, you can do it.
Subject: Displaying Links in View Columns
Notes doclinks are considered rich text and as such cannot be displayed in a view column. You might however consider using a URL.
Subject: Solution: DocLinks in View
The following recipe is a solution (or workaround depending on your point of view) to displaying a link icon in a view which, when clicked, opens a document in another database related to the one displayed in the current view. The solution takes advantage of the InViewEdit feature of Notes.
Assumptions:
-
There is a field on the displayed documents containing a UNID for the related document to be displayed.
-
Actual in-view editing is not required for the view.
First, create a column to display an icon for the link. Enter a formula for the column value as follows:
Icon := 41;
Icon
This value (41) represents the tan dog-eared page icon which is similar to the standard doclink icon. It’s important to use the variable assignment rather than a numeric literal because the Editable Column option will be grayed out and unavailable if a literal is used.
Next, bring up column properties and select the checkboxes for “Display values as icons” and “Editable Column”
Finally, open the view’s InViewEdit event and add the following LotusScript code and modify as necessary to open your target documents.
Dim ws As New NotesUIWorkspace
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim caret As String
Dim URLparts(4) As String
caret = Source.CaretNoteID
If caret = "0" Then Exit Sub 'check for click on a doc, not a category
Set db = Source.View.Parent
Set doc = db.GetDocumentByID(caret)
'build the url to the link target document
URLparts(0) = "Notes:/" 'Notes protocol for the URL
URLparts(1) = db.Server 'this assumes the target db is on the same server as the current db
URLparts(2) = "my/target/database.nsf" 'your db path goes here
URLparts(3) = "0" 'special view placeholder, don't change
URLparts(4) = doc.LinkUNID(0) 'replace with fieldname containing a UNID for the target doc
Call ws.URLOpen( Join( URLparts, "/") )
Hope this helps,
-jerry
Subject: RE: Solution: DocLinks in View
Jerry, thank you!
Subject: Thank-you Jerry, what a fantastic solution!
I was despairing of actually being able to do this, but lo & behold, you did it years ago. Thank-you so much, it works perfectly. In my case, I needed to take advantage of a view’s form formula so I used the View’s UNID instead of the “0” default view. This saved me SO much time.