Sun 2 Nov 2003, 11:31 PM
by Ben Langhinrichs
Notes/Web Coexistence Tip #2
It is so much fun writing technical content on something other than rich text, I'll think I'll throw in another one from my Advanced Notes/Web Coexistence session at the recent UK Admin-Developer Conference. Let me know if you think I should keep posting these coexistence tips or retreat back to my rich text cage. <grin>
Back in Notes R4.6, Lotus added a great new feature, anchor links, with the kind of irritating limitation that seems to plague Lotus when adding great new features. An anchor link lets you go to a specific spot in a document, not just to the document. Anchors are used extensively on the web as a way to point at another part of the same document (table of contents) or to a specific point on a complex page. These were destined to be a big hit in the Notes world, right?
Wrong! As a matter of fact, it is not uncommon to find that developers don't even know they exist, and users, who should be able to use these easily, are not taught to use them at all. Why, because the product management at Lotus did not think hard about how anchors could really be used, and made two crucial mistakes:
1) Anchors cannot be made on their own.
Never mind that anchors on the web are virtually always made separately from the links which point to them. In Notes, you have to make the anchor at the same time as you make the link, meaning that the person making the link to point to the source document must have the ability to modify the target document.
2) Links can't be modified to point to an anchor.
It almost would have been OK to have the first limitation, but the second clinched the problem. If a second person wanted to make a link to a specific document to a specific location, they had to make a new anchor and link, and know what the previous one was called, and know to delete the anchor they just created, etc. etc. It just wasn't usable.
So, as Release after Release of Notes came out, one might have assumed that these issues would be addressed. Unfortunately, they have not been. So, short of using the C API or Midas to create anchors and links to anchors, they have become a very much underutilized feature.
Anchors on Forms
If you think that I have a magic solution to this problem, you're wrong. What I do have is a semi-solution, using yet another feature which isn't documented to work with anchors. While precious little is documented about anchors, it is clear given the only way they can be created that they are not supported on forms. Additionally, even if you could put an anchor on a form, you couldn't create a link to it (see #2 above). But there is a trick, and it works for both the Notes client and the web.
Step 1) In any document with a rich text field, create an anchor link with the desired anchor name. It can be a throwaway document, since you don't really want an anchor link there.
Step 2) Copy the small anchor symbol from where it was created to where you want it on the form.
Now, you have an anchor on the form where you want it. You then have two choices of how to use the anchor. The first is a link that is also on the form, so a long, complex form could have a Go to Top link, for example. In this case, the following steps allow you to set a link to the anchor (which is presumably at the top of the form).
Step A1) Go to the place on the form where you want the link, enter the desired text, such as "Go to Top".
Step A2) Select the text and create an Action Hotspot.
Step A3) Change the client action type to LotusScript and enter the following script (assuming the anchor name is "Top"):
Sub Click(Source As Button)
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Set uidoc = ws.CurrentDocument
Set doc = uidoc.Document
Set uidoc = ws.EditDocument(False, doc, False, "Top")
top.location = "#Top"
Step A5) Make sure the hide-when flags for the action hotspot are set to hide when the document is open for editing, as this code will not work properly unless you are in read mode.
Now you have a functioning anchor and anchor link for both the Notes client and web in a single link, albeit with slightly different code for Notes and web. Now, what if you want to create a link in a rich text field on the document to the same anchor on the form?
You have two choices. One choices is that you can create a link just the way we just did for the form and put it in the rich text field. The second choices is that you can use the Edit - Copy As Link - Anchor Link... and create an anchor link to the document with the exact same name as the anchor on the form, then delete the anchor () tag and make your link as a regular link hotspot, either on this document or another. The link will go to this document, but the spot it will go to is the anchor on the form.
There you have it. Fixed anchors on forms, and code or techniques to link to those anchors. Whether you choose to use this the way it is done on the web, to form a mini-table of contents with links to places on the same document, or to provide a link to specific spot on a different document, you do not have to live with all the limitations that you normally face with anchors. Maybe in Notes 7, IBM will finally address these issues and make it even easier, but until then, make better use of this great feature that has been around since R4.6.
About the title
By the way, if anybody thinks I mistyped the title, and it should be "Anchors away", see this page for a bit of elucidation.
Copyright © 2003 Genii Software Ltd.