Subject: RE: Dialogbox with embedded view - How to pass values
Hello Shane,
thank you for your time spent on this. I’ll definitively give it a try with the demo database or yours.
Now here’s what I ended up with:
The solution consists of three parts
-
The main form from which I’m calling the dialogbox and creating a temp document to open in the dialogbox
-
The temp form, that is displayed in the dialogbox
-
The view, that is embedded in the temp form
-
I’m creating a temp doc and display it in the dialogbox
Sub Click(Source As Button)
Dim nuiws As NotesUIWorkspace
Dim ns As NotesSession
Dim ndb As NotesDatabase
Dim ndDummy As NotesDocument
Set nuiws = New NotesUIWorkspace
Set ns = New NotesSession
Set ndb = ns.CurrentDatabase
Set ndDummy = ndb.CreateDocument
Call ndDummy.ReplaceItemValue("Form","tempForm")
'Initialize any fields of the temp document here
Call nuiws.DialogBox("tempForm", False, False, True, False, False, False, "Your Title", ndDummy, False, True, False)
'Your code goes here. ndDummy contains your data
End Sub
- In the temp form there isn’t really that much. The tricky part was figuring out, where to put that NotesUIWorkspace.RefreshParentNote. I’ll ended up putting it in the terminate event of the form. I’ll come back to this one later because it’s essential
Sub Terminate 'of the temp form
Dim nuiws As NotesUIWorkspace
Set nuiws = New NotesUIWorkspace
Call nuiws.RefreshParentNote
End Sub
- In my embedded view I have 3 action buttons. “OK”, “Cancel” and “Show information”
This one fills the fields in the temp document with values from the currently highlited document in the embedded view. After that it closes the temp document.
Sub Click(Source As Button)
Dim nuiws As NotesUIWorkspace
Dim nuid As NotesUIDocument
Dim ns As NotesSession
Dim ndb As NotesDatabase
Dim ndcInfo As NotesDocumentCollection
Dim nd As NotesDocument
Dim ndInfo As NotesDocument
Set nuiws = New NotesUIWorkspace
Set nuid = nuiws.CurrentDocument
Set nd = nuid.Document 'the temp document
Set ns = New NotesSession
Set ndb = ns.CurrentDatabase
Set ndcInfo = ndb.UnprocessedDocuments 'The document you are displaying in your view and is highlited
If ndcInfo.Count > 0 Then
Set ndInfo = ndcInfo.GetFirstDocument
If Not ndInfo Is Nothing Then
Call nd.ReplaceItemValue("Field1",ndInfo.Field1)
Call nd.ReplaceItemValue("Field2",ndInfo.Field2)
Call nuid.Close
End If
End If
End Sub
Not much to say really, just closes the temp document
Sub Click(Source As Button)
Dim nuiws As NotesUIWorkspace
Dim nuid As NotesUIDocument
Set nuiws = New NotesUIWorkspace
Set nuid = nuiws.CurrentDocument
Call nuid.Close
End Sub
- “Show information” button
This one opens another dialogbox with additional information of the currently highlited document.
Sub Click(Source As Button)
Dim nuiws As NotesUIWorkspace
Dim nuid As NotesUIDocument
Dim ns As NotesSession
Dim ndb As NotesDatabase
Dim ndcInfo As NotesDocumentCollection
Dim nd As NotesDocument
Dim ndInfo As NotesDocument
Set nuiws = New NotesUIWorkspace
Set nuid = nuiws.CurrentDocument
Set nd = nuid.Document
Set ns = New NotesSession
Set ndb = ns.CurrentDatabase
Set ndcInfo = ndb.UnprocessedDocuments
If ndcInfo.Count > 0 Then
Set ndInfo = ndcInfo.GetFirstDocument
If Not ndInfo Is Nothing Then
Call nuiws.DialogBox("informationForm",False,False,True,True,True,True,"Your Title",ndInfo,True,True,False)
End If
End If
End Sub
To make this one fancy, I put some code to the Queryopendocument event of the embedded view, doing almost the same as the “OK” button, that’s put the values in the temp doc and close it.
Sub Queryopendocument(Source As Notesuiview, Continue As Variant)
Dim nuiws As NotesUIWorkspace
Dim nuid As NotesUIDocument
Dim ns As NotesSession
Dim ndb As NotesDatabase
Dim ndcInfo As NotesDocumentCollection
Dim nd As NotesDocument
Dim ndInfo As NotesDocument
Set nuiws = New NotesUIWorkspace
Set nuid = nuiws.CurrentDocument
Set nd = nuid.Document
Set ns = New NotesSession
Set ndb = ns.CurrentDatabase
Set ndcInfo = Source.Documents
If ndcInfo.Count > 0 Then
Set ndInfo = ndcInfo.GetFirstDocument
If Not ndInfo Is Nothing Then
Call nd.ReplaceItemValue("Field1",ndInfo.Field1)
Call nd.ReplaceItemValue("Field2",ndInfo.Field2)
Call nuid.Close
End If
End If
Continue = False
End Sub
Now really a pain was, that I was not able to do this within one click for the user. He had to click first on the view action, and after that on the OK button of the dialogbox to get the populated fields from the temp document accessable in the calling script of the main form.
Here the NotesUIWorkspace.RefreshParentNote comes into place. It didn’t work in any of those well known events like the click event of the views action button, or the queryclose event of the temp form. So I ended up trying and… tada… found a place where it DOES work: the Terminate event of the temp form.
Now that’s not good style, maybe it’s a hack, but you stick with what you’ve been given, don’t you?
Hope this one helps some people out there.
Thanks to all for sharing.
Cheers
Jens