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