Point hotspots to a field on the document

I’ve created a Notes database that allows users to create content in the Notes client which is then served on the web. Part of what they need to do is enter a URL in a field on the document, and then be able to create a hotspot in the actual content rich text field that points to the page indicated in the URL field.

So I have a field called URL1 and in that field I enter “http://www.companysite.com/mydocument” and then in the Body field which is actually hosted on the web, I create text or an image and then create a hotspot around the text or image and point that hotspot to the value in the URL field.

I’ve tried a few things and so far, nothing works. Any help would be greatly appreciated!

Thanks in advance.

Subject: Point hotspots to a field on the document

Have you tried creating an tag pair programatically in the rich text field where you want the link to go? This should create the link when converted to html by the browser. You can also build an image tag with a link. Ultimately, that’s what’s going to matter: the html you end up with in the rtf field on the web.

Subject: RE: Point hotspots to a field on the document

Thanks, Joel. I’ll try and play with that today but could you provide a little more information about what you have in mind?

This has to be relatively easy to do for the user. It’s OK to have the user select text or a graphic and create a Hotspot in Notes which points to another field in the same document, but I don’t want to force the user to to type in pass-thru HTML by hand.

Thanks again!

Subject: RE: Point hotspots to a field on the document

The end user would enter the URL in a provided text field in the Notes Client and perhaps selectthe file name for the image they want to use from a dropdown list (so you can provide the images

in image resources or attached to separate documents)

There would next be a button which, when clicked would insert the code into the rtf at the place where the cursor

is. This would be done in LS and you could have additional code to place the cursor after the last paragraph (or at the beginning)

if the insertion point when the button is clicked is NOT in the rtf field.

Thus, the users select a graphic file name, and enter the url and the tag is created in the rtf field.

The code below adds an IMAGE to an rtf field. You can modify it to add an image with a link on it.

Sub Click(Source As Button)

Dim ws As New NotesUIWorkspace

Dim currdoc As NotesUIDocument

Dim doc As NotesDocument

Dim dc As NotesDocumentCollection

Dim cfgview As NotesView

Dim cfgdoc As NotesDocument

Dim oldImageName As String

Dim oldImage As String

Dim newImageURL As String

Dim newImage As String

Dim oldImageURL As String	





Set currdoc = ws.CurrentDocument

f$ = currdoc.CurrentField

If (f$ <> "body") Then

	Call ws.Prompt(PROMPT_OK, "Error inserting tag!", "You have to be in the Body field to insert a tag.")

'You could also change the insertion point here using the rtf classes in LS.

	Exit Sub

End If



If (currdoc.FieldGetText("imageURLs") = "") Then

	Call ws.Prompt(PROMPT_OK, "Error inserting image!", "You must create an Image Set before trying to insert an image.")

	Exit Sub

End If



oldImageURL = ""

If ws.DialogBox("InsertImageDialog", True, True, False, False, False, False, "Dialog Box", currdoc.Document) Then

	' get the name of the old image

	oldImageName = currdoc.Document.GetItemValue("DialogBoxDropDown")(0)

	Print "oldImageName=" & oldImageName

	

	oldImageURL = currdoc.Document.GetItemValue("DialogBoxDropDownValue")(0)

	Print "oldImageURL=" & oldImageURL

End If



nl$ = Chr$(13) + Chr$(10)



Call currdoc.InsertText({<img src="} & oldImageURL & {">}  & nl$)

End Sub

Subject: RE: Point hotspots to a field on the document

Wow, Joel, thanks VERY much for all the help. I’m certainly going to give this a try.

Users need to be able to put whatever text or images they like, including new images I haven’t seen before, so I can’t give them a set list of images but I’ll take a look at this code and see what we can do with it.

But there’s no way to just reference the contents of another field in any kind of hotspot definition?

Subject: RE: Point hotspots to a field on the document

Sure you can. A hotspot URL can be computed, and could therefore use the value of another field.Just use the formula for the URL (see picture below)

Subject: RE: Point hotspots to a field on the document

Thanks so much. I’ll give this a try!

Subject: RE: Point hotspots to a field on the document

Thanks very much for the solution, Ben. Unfortunately while it works in the Notes client it doesn’t seem to work when the document is published on the web. I get this server error, which points to the document containing the link fields:

HTTP Web Server: Lotus Notes Exception - @SetDocField and @GetDocField cannot access the document currently being computed [/DATABASE.NSF/DocsByNumber/SOP-0011?OpenDocument]

Is there some other way to programatically access the current document in a URL reference? So far I’ve tried @DocumentUniqueID and @Text(@DocumentUniqueID) with no luck.

Thanks again!

Subject: RE: Point hotspots to a field on the document

For the current document, you can just use the fieldname, but make sure it is above or to the left of the computed value so that it will compute properly the first time.

Subject: RE: Point hotspots to a field on the document

It looks like this is working perfectly, in Notes and on the web! Thanks so much, Ben!

Subject: RE: Point hotspots to a field on the document

oldImageURL = currdoc.Document.GetItemValue(“DialogBoxDropDownValue”)(0)Print “oldImageURL=” & oldImageURL

End If

This code merely looks at a computed field. The value of the url is computed from a list of image urls that have been created when the end user attaches the files to documents in the database that store them. The dialdogbox field is computed when the document is created and can be a dbcolumn of the values in a view containing the attachment documents. In this way, users can attach images to documents in the database, and use this list to build an url to the images on those documents.