Reputation: 11
I have wrote the follwing code o get the parent UNID of a response document. But I am getting "Invalid universal ID" error. But when I create a doclink using the "$Ref" I am able to access the parent doc using doclink. I want to access the parent document and change the one of the field in parent document. Can anyone suggest anything?
Dim session As New NotesSession
Dim db As NotesDatabase
Dim uiwork As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim parent As Notesdocument
Set db = session.CurrentDatabase
Set uidoc=uiwork.currentdocument
Set doc = uidoc.Document
'Set parent = db.GetDocumentByUNID(doc.ParentDocumentUNID)
Set parent = db.GetDocumentByUNID("doc.$Ref")
'both methods are giving same error
Upvotes: 1
Views: 7626
Reputation: 1
Thanks Tim. I wrote the code in QuerySave and it worked fine. It was giving invalid UNID because I was trying to get it before the document is saved.
Upvotes: 0
Reputation: 61
what does doc.isresponse return?
using parent unid should be fine. However
==>Set parent = db.GetDocumentByUNID("doc.$Ref")
is invalid, should have been:
if doc.hasItem("$Ref") then
Set parent = db.GetDocumentByUNID(doc.~$Ref(0))
end if
or
if doc.hasItem("$Ref") then
Set parent = db.GetDocumentByUNID(doc.getItemValue("$Ref")(0))
end if
Upvotes: 3