Dialogbox with embedded view - How to pass values

Hi all,

i have a form that opens a dialogbox. In this dialogbox an embedded view is placed. In order to get the focus right I’m using an action of the embedded view to populate a field in the document that is displayed in dialogbox. Works like a charm so far.

My problem is, how to get this value passed to the underlying document without having the user click first on the action button (seems necessary so far) and after that clicking on the ok button of the dialogbox.

I’m aware that there is refreshparentnote. However this would only work if i put it in a hotspot button on the dialogbox form. I tried to put it in eihter the action button of the embedded view or in the queryclose event of the dialogbox form both getting the error “Notes Error - specified command is not available from the workspace”.

So to sum it up I want to achieve that the user picks a row from the view, pushes ONE button and he is done and the underlying form is updated with the key value of that row.

I’m also aware that this could be done by a picklist but due to some reasons (there is another button that opens additional info for the selected row) I don’t want to use a picklist.

Any help would be highly appreciated.

Jens

Subject: Dialogbox with embedded view - How to pass values

I normally use environment variables to pass this type of information. In queryclose of your dialog box form, set an environment variable which would make it available to your underlying form.

Subject: RE: Dialogbox with embedded view - How to pass values

I am going to make this post assuming you can populate the field in the form displayed in the dialogue box by clicking on the document in the view.

e.g. I assume that if a user opens the dialog box they can click on a document in the embedded view and the field on the documentis populated. If not I’ll post some more later.

With the dialogg box I have found the best way to get data basck is to pass a Notesdocument into the dialog box and then get the values off the document you have passed in. I have appended a sample of a Move Or Copy dialog box I use as part of my standard tool boxc. It creates a documentin the database, saves it (else the doc sometimes doesn’t return items with data) gives the document a form name and opens the document in the dialog box.

If the dialogbox is returned as ok clicked the underlaying document is checked for the item which contains the return I want.

you do not want a user to click an ok button, just a document in the embedded view. The embedded view has events for single click or double click of a document. Catch that event, place the data from the clicked / selected document into the form / document being displayed in the dialog box and then have the event close the dialog box window. closing the window mnight be able to happen either viia a uiworkspace window close or maybe by faking a key stroke (esc, esc maybe?) to close the dialog box.

HTH

shane

<SnIP - sample dialog box bleow>

Function dlgMoveCopy( title$ ) As String

’ *******************************************

’ Opens a dialog box with a choice of Move or Copy

’ and chooses one of the following strings

’ MOVE - Move was choosen

’ COPY - Copy was choosen

’ CANCEL - Cancel was choosen

’ Error …something blew up

’ *******************************************

On Error Goto errHandle

Dim w As New NotesUIWorkspace 	

Dim s As New NotesSession 

Dim db As NotesDatabase 

Dim doc As NotesDocument 	



Set db = s.CurrentDatabase 

Set doc = New NotesDocument( db )

Call doc.Save( True, False)



If title$ = "" Then 

	title$ = "Move OR Copy?"

End If



If w.DialogBox( "dlgMoveCopy" , True , True, False , False , False, False , title$ , doc ,False , False , False ) Then 

	dlgMoveCopy = doc.MoveCopy(0)

	

Else 'Cancel Pushed

	dlgMoveCopy = "CANCEL"

	

End If 'w.DialogBox

stdExit:

On Error Resume Next

Call doc.Remove(True)



Exit Function

’ ****** Error Handling *********

errHandle:

Msgbox "There was an error while trying to choose to move or copy" & Chr$(13) & "Err Msg: " & Error$, 48, "[dlgMoveCopy] Error  (" & Cstr(Erl) & ")"

dlgMoveCopy = "ERROR"		

Goto stdExit

End Function

Subject: RE: Dialogbox with embedded view - How to pass values

Your problem intrigued me so I played.

There is a demo of my results downloadable here. It is a zipped NSF file with two forms, a view and an agent as well as four demo docs. The default ACL is Manager.

The link will last for 7 days and is public to get to.

Run the agent form the Actions menu.

Double click on the doc you choose and it will return the value in the second column to you in a Msgbox. The code is all easy to follow and short.

You may have to be quite firm in your doble click of the doc in the embedded view but once you have double clicked it just wait half a second and it will close the dialog box and return the value.

The embeded view is worked from the InviewEdit event of the view, gets the doc using the CaretID and closes the dialog box using the uiworkspace.close method.

Enjoy.

Subject: RE: Dialogbox with embedded view - How to pass values

I know it’s almost a year later, but any possibility of getting a re-post of your solution?

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

  1. The main form from which I’m calling the dialogbox and creating a temp document to open in the dialogbox

  2. The temp form, that is displayed in the dialogbox

  3. The view, that is embedded in the temp form

  4. 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

  1. 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

  1. In my embedded view I have 3 action buttons. “OK”, “Cancel” and “Show information”
  • “OK” button

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

  • “Cancel” button

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

Subject: RE: Dialogbox with embedded view - How to pass values

Ok … everybody on the list, chant with me now …

Guru …gu …ru…GUUUUUUUUUU…RUUUUUU!!!

Well done Jens, like Einstein(?) said … Genius is 10% inspiration and 90% persperation … looks like you qualify as genius here.

The only thing my code adds to what you have done is to catch the double click on the doc and close the form.

With you already updating the parent note on the query open the only change to your code you would need to make is to close the form using my code on the InViewEdit event.

Again well done. An honourable hack! :slight_smile:

Shane

Subject: RE: Dialogbox with embedded view - How to pass values

Hi again,

thanks for the kudos. Sorry for the late response, was pretty busy and then gone off for holidays.

I tried your enhancements to the code and you might be interrested to hear that my customer very much liked the overall application :slight_smile:

So again thanks for the help.

Jens

PS: Where did you get to know the “Guru” Chant? It’s kinda famous in Germany and Austria, called “Drei weiße Tauben” - mostly played at the Oktoberfest :slight_smile:

Subject: Thank-you, Thank-you, Thank-you!!!

I realize this is an old post but you just saved me from hours of trying to figure out why the refreshparentnote wasn’t working. Adding to Terminate did the trick!