How can I create a docllink (by using Appenddoclink) on the form?

Hi,

How can I create a docllink (by using Appenddoclink) on the form?

The code below currently works for the button. I am trying to figure out the way to use appenddoclink instead of the button. For example, on the form, when the user enters the group name into the field, and saves the form (after he/she is done). If the group does exist in the address book database, then that field (groupname) should be “doclink” (by using this syntax: Call nrtiNotice.AppendDocLink(compare_doc, ListName, ListName)) so when the user clicks on that link, then they will be redirected to the address book database. If the group does not exist in the address book database, then it there is not link, however, the name of the group should appear in the field as usual.

====================

Sub Click(Source As Button)

Dim session As New notessession

Dim curdb As NotesDatabase

Dim nabdb As notesdatabase

Dim curdoc As NotesDocument

Dim nabdoc As NotesDocument

Dim workspace As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Dim nablookupview As notesview

Dim servername As String

servername=“XXXXX”

Set curdb=session.currentdatabase

Set nabdb=New notesdatabase(servername, “names.nsf”)

Set uidoc = workspace.CurrentDocument

Set curdoc=uidoc.document

Set nablookupview=nabdb.GetView(“($VIMGroups)”)

Set nabdoc=nablookupview.GetDocumentByKey(curdoc.listname(0), True)

If nabdoc Is Nothing Then

Msgbox “Document for group “+curdoc.listname(0)+” is not found in NAB”

Else

Call workspace.EditDocument(False, nabdoc, False)

End If

End Sub

===================================

Thanks,

Mike Woo

Subject: Example - Appenddoclink?

Dim session As New NotesSession Dim db As notesdatabase

              Dim doc As NotesDocument, memo as NotesDocument

              Dim rtitem As NotesRichTextItem



              Set db = Session.CurrentDatabase 

              Set doc = session.DocumentContext

              set memo= New NotesDocument(db) 

              

              memo.form="Memo"

              memo.SendTo = "LN USer"

              memo.Subject = "Testing"



                                set rtitem = New NotesRichTextItem(memo, "Body")



              Call rtitem.AddNewLine(1)

              Call rtitem.Appendtext("Click here to launch the document 

              -->") 

              Call rtitem.AppendDocLink(doc,"Title")

              Call memo.Send( False )

Subject: how do you integrate into the appenddoclink into the form?

Hi Michael,

how do you integrate into the appenddoclink into the form?

Thanks,

Mike Woo

Subject: RE: how do you integrate into the appenddoclink into the form?

Please be careful with your terminology. You don’t want the doclink on the form. You want it in the document, specifically in a rich text field.

It’s not simple to update the contents of rich text while the document is still open. We have discussed this here and in the R4/5 forum often, and solutions were given.

The specific problem you describe, of automatically creating hotlinks based on values the user enters in a field, can be addressed in other ways in ND6. For instance, you can hide the field in edit mode, and use Computed Text to create passthru HTML hotspots using the values in the field and the (@dblooked-up) UNIDs of the referenced documents, to create Notes URL links to the documents.

Subject: RE: how do you integrate into the appenddoclink into the form?

Hi Andre,

Thanks for the suggestions. This is not a web-based application, so I don’t have URL (or html) for the link.

Can you give me more details how to resolve this issue? If this is not an-easy issue, then how can I create a seperate doclink (appenddoclink) next to that link? I think that this is easier right?

Thanks,

Mike Woo

Subject: RE: how do you integrate into the appenddoclink into the form?

You can use HTML and URLs in a Notes client application. The Notes client can
“render” the passthru HTML into links.

Let’s suppose you have a field named Groups and you want to display it in read
mode as a bunch of links. Suppose there’s a view ByGroupName where the group
documents are sorted by name. You could do something like this:

_urlStart := “notes://” + @Name([cn]; @DbName[1]) + “/” + @ReplicaID + “/0/”;
REM “That assumes the documents are in the current database. If not, adjust
accordingly.”;
_links := @Transform(Groups; “x”;
@Do(
_tmp := @DbLookup(“”; somedb; “ByGroupName”; x; 1;
[RETURNDOCUMENTUNIQUEID]);
@If(@IsError(_tmp); x; "A HREF=" + _urlStart + _tmp + “">]” + x +
“/A>]”)
)
);
@Implode(_links; ", ")

This formula would be in a Computed Text area or CFD text field.

Subject: RE: how do you integrate into the appenddoclink into the form?

Hi Andre,

Thanks for the response. I’ve have never done that before, but I learned something from you most likely on every posts.

Anyway, I am trying to create a doclink for one of the fields, and RTDocLink field is type of RichText, computed. I have the following code and it’s not working, I don’t see the field when I open the form after the user saves it.

What am I doing wrong in here?

Dim Doc As NotesDocument

Dim nrtiNotice As NotesRichTextItem

Dim workspace As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Dim curdoc As NotesDocument

Set Doc = Source.Document

Set uidoc = workspace.CurrentDocument

Set curdoc=uidoc.document

Set amat_lookupview = amat_db.GetView(“Groups”)

Set amat_doc=amat_lookupview.GetDocumentByKey(curdoc.ListName(0))

If curdoc.IsNewNote Then

Set nrtiNotice = curdoc.GetFirstItem(“RTDocLink”)

If (nrtiNotice.Type = RICHTEXT ) Then

’ Messagebox “Inside the if statement”

’ Set nrtiNotice = New NotesRichTextItem(doc, “RTDocLink”)

Call nrtiNotice.AppendDocLink(curdoc, ListName, ListName)

Call curdoc.Save(True, True)

End If

End If

This code is in querrysave.

Please let me know if you need more information.

Thank you.

Mike Woo