Ways to pass uidoc object to another form

I wonder that is there any possibility to pass uidoc object from currently opened new document in workspace to another document - for instance: response to the main document.

The uidoc object is needed in Queryclose event of response document to update values on main opened form in workspace.

Any help, hint will be nice :slight_smile:

Regards

Liwiusz

Subject: Ways to pass uidoc object to another form

Not directly. The code on the separate form effectively has its own environment.

The first approach that comes to mind to achieve what you are suggesting is to use inheritance where the UNID of the original document is inherited by the second document being opened. It should be an easy step to GetDocByUNID in the PostOpen event of the second form.

Subject: RE: Ways to pass uidoc object to another form

It is easy when the main document is already saved to the database. There is no problem to find doc UNID and refresh values on currently opened main form in workspace (in edit mode) from Queryclose event of the response doc.

Problem is when the main document that is in edit mode is not saved to the database (completely new document in edit mode) and users create “response” document to the main which inherit values. After save the “response” I can not find reference to the main document.

“response” means that is not a classic response document but regular document than inherit values from main doc because there is now way to save response document when the main doc is not saved to the database.

Have you any ideas how do the trick?

Regards

Liwiusz

Subject: RE: Ways to pass uidoc object to another form

OK here is an approach I have used before. It opens a temporary new document and pre-populates a field then looks up all the relevant info from the real doc. The new document is NOT saved. The real doc IS saved. The field that gets passed could be a UNID or a unique key for accessing the existing document. I do not currently have access to the other database, but my recollection is that the new UIDoc has to populate its field with a QueryOpen/PostOpen event which looks up the existing doc.

Sub Initialize

Dim ws As New notesuiworkspace

Dim s As New notessession

Dim db As notesdatabase

Dim Docdb As notesdatabase

Dim ParDoc As notesdocument

Dim doc As notesdocument     

Dim pardc As notesdocumentcollection	



Set db = s.currentdatabase	

Set Docdb = New Notesdatabase( db.server, "secondDB.nsf" )

Set pardc = db.unprocesseddocuments

If pardc.count > 1 Then

	Msgbox "You cannot open more than 1 folder at a time"

	Exit Sub

End If



Set ParDoc = pardc.getnthdocument(1)

Set doc = Docdb.createdocument

doc.form = "fTempForm"

doc.FieldToBePassed = pardoc.FieldToBePassed(0)



Call ws.editdocument(True,doc)  

End Sub