Question

I have an agent that takes a copy of a template document and puts in values from a text file.

I am running into a problem when adding a hyperlink to a field programmatically, If I just add the text (e.g. http://www.google.com) there is no hyperlink just plain text. If I add the text manually, by editing the document just adding the address works fine and is clickable.

I have tried creating a rich text object then adding that to the field but that doesn't work either :(

Set rtItem = New NotesRichTextItem( doc, "link" )
Call rtitem.AddNewLine( 1 )
Call rtItem.AppendText ("http://www.google.com")
doc.AppendItemValue "Details", rtItem

To be clear, I'm looking for a way to append a clickable hyperlink to a field using lotusscript. Any help would be greatly appreciated.

EDIT: Upon further inspection if I generate a document with a link in the text field and save it (programmatically using doc.save) it saves as plain text, as soon as I then go into this document and do a manual save the plain text turns into a link just fine. Could something be wrong with how I am saving?

If  (Not doc.save(True,False,True)) Then
    Msgbox("Document could not save")
End If
Was it helpful?

Solution

It does work the way you tried in your code with just "AppendText". But, the link works only if the document is in read mode and client property "Make Internet URL ... into Hotspots" is set.

enter image description here

UPDATE:

AppendItemValue doesn't work for RichTextItems.

Append the link direct to your field "Details" or if it doesn't exist then create it. Your code should look like this:

Dim rtItem As NotesRichTextItem
If doc.Hasitem("Details") Then 
    Set rtitem = doc.Getfirstitem("Details")
Else 
    Set rtitem = doc.Createrichtextitem("Details")
End if
Call rtitem.AddNewLine( 1 )
Call rtItem.AppendText ("http://www.google.com")
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top