uiview.deselectAll and "Command is not available"

I have a form with an embedded view. On the action bar of the view (not the action bar of the form, but the embedded view), I have a button that will delete the selected documents, or if no documents are selected it will delete the currently hilited document. Deleting the hilited document works fine. When I try to delete the selected documents I ran into a few problems. The main problem is that although the documents do delete properly and the view does refresh, if the button is clicked again, it acts as though the documents from before are still selected. I thought this was easily solved by adding “call uiview.deselectAll” to the script. When I do this, it gives me “Command is not available”. No matter where I put the deselect, it gives me that error unless I put it above the messageboxes in the script. I tested a few things and found out that it works fine as long as the focus is not taken away from the view like it is when a messagebox is displayed. The button works fine when the view is not embedded regardless of where I place the deselect and regardless of any messageboxes.

I tried to get around this problem by refreshing the form the view is embedded on, but this crashes the client. I also tried putting the deselect in the view’s PostOpen event thinking it would run when the view is refreshed and it gives me the same error, “Command is not available.”, when I open the view and simply doesn’t run on a refresh.

I’m out of ideas and any suggestions would greatly help. I am including my code below.

Oh, I also tried to do the same thing in @Formula but I would get a similar, though not the same, error when @Prompt preceded the EditDeselectAll. I have not yet tried this in Java but I’m assuming I will get the same error as when I run it in LotusScript as the @Formula also had a similar error.

Sub Click(Source As Button)

Dim ws As New NotesUIWorkspace

Dim uiview As NotesUIView

Set uiview = ws.CurrentView



Dim collection As NotesDocumentCollection

Set collection = uiview.Documents



If collection.Count > 0 Then

	If Messagebox("Are you sure you wish to delete the selected document(s)?",36,"Delete?") = 6 Then

		Call uiview.DeselectAll			

		Call collection.RemoveAll(True)

		Call ws.ViewRefresh

	End If

Else

	If Messagebox("Are you sure you wish to delete the hilighted document?",36,"Delete?") = 6 Then

		Dim doc As NotesDocument

		Set doc = ws.CurrentDatabase.Database.GetDocumentByID(uiview.CaretNoteID)

		Call doc.Remove(True)

		Call ws.ViewRefresh

	End If

End If

End Sub

Subject: uiview.deselectAll and “Command is not available” - bug

Ok, after some more testing, I don’t think this is a problem with my code as much as is a bug in Notes. When the view is an embedded view, any time a messagebox is displayed, it takes the focus away from the view and half of the uiview methods appear not to work. Specifically I tried deselectall and selectdocument. I also tried to get a handle on the view again with ws.currentview, but then it gives me an “Object variable not set” when I try to call the uiview. The Print method does still work. I haven’t tried the Close method as its an embedded view.

So how do I go about reporting this the the powers at Lotus/IBM for them to look into and hopefully fix?

Subject: RE: uiview.deselectAll and “Command is not available” - bug

This is a bug or for Lotus probably a designed feature. ;-(

Put your code in an agent instead of the action directly. Call this agent in the action. Then the selected documents are not still selected. Not very logical, but it works.

Try it.