[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 473
  • Last Modified:

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

0
jkee54
Asked:
jkee54
1 Solution
 
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
 
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now