Embedded view -- how to find out what's selected?

Hi all:

I must be missing something very basic here. Any help greatly apprecaited.

I have an embedded view on a form, running in the notes client (not a domino/web application) and I can’t figure out how to determine which rows in the view have been selected so I can act upon them when the user clicks a button on the form.

Thanks

Mohib

Subject: embedded view – how to find out what’s selected??

It’s possible to obtain a collection of the selected documents from the events in the view itself or from view actions (see NotesDatabase.UnprocessedDocuments).

An interesting thing is that NotesUIWorkspace.CurrentDocument used from the context of an embedded view event or action will give you a handle on the enclosing Notesuidocument around the embedded view.

I haven’t seen this documented, but extensive testing has seen it working reliably.

Also make sure the view is used only as an embedded view, as the method will likely return nothing or an error in the context of a free-standing view.

You can then grab whatever values you need off the returned Notesuidocument (via FieldGetText) and use it however you see fit in conjunction with the selected document collection.

So it is possible, but driven from a view action rather than a form action.

Example code, View Action:

Sub Click(Source As Button)

'Examples sets Status field on embedded

'view selected documents to value of Status

'field on open enclosing document.

dim uiw as New NotesUIWorkspace

dim uid as NotesUIDocument

dim ses as New NotesSession

dim colSelected as NotesDocumentCollection

dim strStatus$

'Get the status from the enclosing document.

set uid = uiw.CurrentDocument

strStatus = uid.FieldGetText ( “Status” )

'Get the documents selected in the view.

set colSelected = ses.Currentdatabase.UnprocessedDocuments

'Set the status of the collection.

call colSelected.Stampall ( “Status”, strStatus )

End Sub

Subject: RE: embedded view – how to find out what’s selected??

Thanks!!

All that worked perfectly, except that because my form with the emebdded view is opened in a dialog box, and the action I want to do is open the selected documents, Notes won’t allow that to happen :(( since the dialog box has control of the UI.

I suppose I could save the UNIDs of the selected documents in a profile document for the user and then open them all in the form’s Terminate event, as long as the dialog box is off the screen by then. But it seems a bit of a patch however and messy to explain to the users.

Thanks anyway as I had been looking for that info as it allows me to make richer UI’s and forms.

Mohib

Subject: RE: embedded view – how to find out what’s selected??

Yes, you will strike problems opening documents from a dialog box, a very unusual thing to do. Is it possible that you just need to take a step back and rethink the interface? Generally where you strike problems like this, it indicates changes in the high-level design might be more appropriate.

Also don’t forget that R6 has some nice view picklist dialog box functionality, that may offer some alternatives if you need to stick with the dialog boxes.

Hope it helps anyway and good luck.