Invalid Universal Id Error!

Hi,

I have two forms (parent and child). I am creating a child document and saving it. It is throwing an error as “Invalid Universal Id”.

My code is as below :

Below code is written in Click event of an action button in the child form.

Sub Click(Source As Button)

           Dim ws As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Dim doc As NotesDocument

Dim session As New NotesSession

Dim db As NotesDatabase



Set uidoc = ws.CurrentDocument	

Set doc = uidoc.Document



Set db = session.CurrentDatabase



parentunid = doc.ParentDocumentUNID



Dim parentdoc As notesdocument

Set parentdoc = db.GetDocumentByUNID(parentunid)

'Set parentDoc=db.GetDocumentByUNID(parentUNID)

Call doc.MakeResponse(parentdoc)

Call uidoc.Save

uidoc.Close

End Sub

In Post Save of the child form i have written the below code.

Sub Postsave(Source As Notesuidocument)

Dim doc As notesdocument

Dim parentDoc As notesdocument



Set doc = source.Document



Dim session As New NotesSession

Dim db As NotesDatabase

Set db = session.CurrentDatabase



'Set parentDoc=db.GetDocumentByUNID(parentUNID)

'Call doc.MakeResponse(parentDoc)

Call doc.Save(True,True)

End Sub

Please help me as i am unable to fix this.

Regards,

Sai.

Subject: Invalid Universal Id Error !

Hi,

has the parent document already been saved when You call the db.getdocumentbyunid () method? If not so, save it first and then create the child document.

Hope it helps…

Andreas

Subject: Invalid Universal Id Error !

Aaah…the old cart before the donkey problem!

You have this line in your code:

parentunid = doc.ParentDocumentUNID

Followed a few lines later by:

Set parentdoc = db.GetDocumentByUNID(parentunid)

And then:

Call doc.MakeResponse(parentdoc)

The problem is ‘doc.ParentDocumentUNID’ will only return a value AFTER it has been made into a response document. So before doc becomes a response ‘doc.ParentDocumentUNID’ will always return a null value.