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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
Sjef BosmanGroupware 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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.