"Invalid universal id" error while getting parent UNID for Lotus notes
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开发者_C百科 error
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
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.
精彩评论