Put doclink in new document - need help debugging

I have this code in the post save event of a document that I want to create a new form and have a link in it back to the original.  It won't let me save, giving the error

"Postsave: 23: Not a member: APPENDDOCLINK"

on this line
Call rtitem.AppendDocLink(UIDoc ,"click to open")

I'm a script novice and copied/modified this code from another place where it works, but I must have modified something wrong.

Help!


Dim ws As New NotesUIWorkspace
Dim session As New notesSession
Dim UIDoc As NotesUIDocument 'audit
Dim newdoc As NotesDocument 'mgr review
Dim db As NotesDatabase
Dim rtitem As NotesRichTextDocLink
Dim srce As NotesUIDocument
Set db = Session.CurrentDatabase
Set UIDoc = ws.CurrentDocument
Set newdoc= New NotesDocument(db)
Set rtitem = New NotesRichTextItem(newdoc,"auditlink")
Set srce = ws.CurrentDocument
Set curDoc = srce.Document
Set newdoc = db.CreateDocument
	
If (UIDoc.FieldGetText ("EScore") <96) Then
	Call rtitem.AppendDocLink(UIDoc ,"click to open")
	Call newdoc.ComputeWithForm(True, False)
	Call newdoc.Save(True,False)
End If

Open in new window

jkee54Asked:
Who is Participating?
 
Sjef BosmanConnect With a Mentor Groupware ConsultantCommented:
There are more problems than what you mention: on line 10, a newdoc is created, then on line 11 the rtitem, and finally on line 14 newdoc is re-created. Thereby removing the original newdoc AND the rtitem! Furthermore, rtitem is wrongly declared as NotesRichTextDocLink instead of NotesRichTextItem. Next, FieldGetText always returns a text value, so you cannot compare it to the integer value 96. Lastly, a ComputeWithForm is done without defining the form first...

Dim ws As New NotesUIWorkspace
Dim session As New notesSession
Dim UIDoc As NotesUIDocument 'audit
Dim newdoc As NotesDocument 'mgr review
Dim db As NotesDatabase
Dim rtitem As NotesRichTextItem

Set db = Session.CurrentDatabase
Set UIDoc = ws.CurrentDocument
Set curDoc = UIDoc.Document
Set newdoc= New NotesDocument(db)
Set rtitem = New NotesRichTextItem(newdoc,"auditlink")
       
If (curDoc.GetItemValue("EScore")(0)<96) Then
        Call rtitem.AppendDocLink(curDoc ,"click to open")
        Call newDoc.ReplaceItemValue("Form", "your form's name")
        Call newdoc.ComputeWithForm(True, False)
        Call newdoc.Save(True,False)
End If
0
 
johnjardinCommented:
Hi There. You cannot pass a NotesUIDocument Object to the appenddoclink method. You can only pass a NotesDocumentObject.

Add the following to your code:

dim doc as NotesDocument


after the code:

Set UIDoc = ws.CurrentDocument

add this code:

set doc = uidoc.Document

then your appenddoclink should look like this:

call rtitiem.AppendDoclink( doc, "click to open" )

hope this helps
0
 
jkee54Author Commented:
I appreciate the coaching, especially the time you took to explain.  I  learn best by example, and/or modifying existing code, and your answer went a long way towards helping me.  Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.