Accessing NotesUIView methods from a form

I have a mechanism set up to allow users to batch process the values of multiple fields. They select the documents to process, then click a button which opens a form containing all available fields. They select the values on the form, then click a button which processes all selected documents.

This works correctly - I get a handle to the NotesUIView in the QueryOpen of the form by using Set uiv = NotesUIWorkspace.currentview, then get a handle to the selected documents in the action bar button by using Set dc = uiv.documents.

The problem is, I want to deselect all documents and refresh the view when the batch process button is clicked in the form - otherwise, when the form closes, the documents remain selected. Since they may have moved to different categories, users can frequently forget to deselect them. So I tried this at the end of the batch process button:

Call uiv.View.Refresh

Call uiv.DeselectAll

Call ws.ViewRefresh

Now this code works just fine when called in a button directly in a view, but when I try it in a button in a form, I get “Command not available” on the DeselectAll line.

Can someone explain to me how it is that I can get a handle to the uiv and access the Documents property of it, but I can’t call the DeselectAll method? I had thought that once I had a handle to the object I could access all of its methods and properties.

Subject: Accessing NotesUIView methods from a form

I think that all you have to do is to DeselectAll immediately following opening the form. In other words, the DeselectAll should not be triggered from the form, but from the original button. I think the form will still recognize them as being selected.

Subject: RE: Accessing NotesUIView methods from a form

Thanks, but I still get the error message. I have specific error trapping, so I know that the error is now coming from the initial button, not the form button, but it’s still causing the error one way or another.

Subject: Accessing NotesUIView methods from a form

Esther,

Where is uiv declared and where do you attempt to perform the deselectAll? If uiv is declared in your form (either global form declarations or glov=bal variables) and you attempt to use it in your batch process that may be an agent outside of the declaraition scope, then you will not be able to work with it.

My suggeston is to either perform the deselectall after returning from the batch process if that is running through some function, or alternatively, pass uiv to the function and then have the function perform the deselectAll. Last, you could declare it as a global variable in a script library that is set by the form’s PostOPen but then processed by your batch process (so long as that batch process doesn’t use its own “instance” of the script library)

Subject: RE: Accessing NotesUIView methods from a form

uiv is dimmed as a global form variable, and set in the PostOpen of the form. It’s not being used in an agent outside of the scope - the batch process is simply an action button on the form - all code is in the button, not an agent or script library. If I can access the document collection (i.e. NotesUIView.Documents), that means I have a handle to the NotesUIView. So why shouldn’t I be able to access all the other methods of the object?

Subject: RE: Accessing NotesUIView methods from a form

I know that the Designer UI is at least partly to blame for this lack of clarity, but when you say:

“uiv is dimmed as a global form variable”

and supposing that your form is named Batch, do you mean that it is dimmed in the the (Declarations) section under (Globals)Batch or is it dimmed n the the (Declarations) section under Batch (Form)? If the latter, then it will not be visible to the Actions on the form. If the former, then it looks like somehow the variable you set loses its context and is set to Nothing.

Subject: RE: Accessing NotesUIView methods from a form

It’s under Globals → Batch. What could make it lose its context, but leave the document collection available?

Subject: RE: Accessing NotesUIView methods from a form

Hmmm - you got me there. Perhaps if the UIView is somehow obscured because a form opened up over top of it… Don’t know - just guessing at this point.

Subject: RE: Accessing NotesUIView methods from a form

I would bet what is happening is that if the form is opened over the top of the view, that only UIDocument commands are available. Yes, she has a handle to the uiview from her queryopen action, but when she clicks the form button, she is doing the equivalent of this line of code:

Call ws.uiview.DeselectAll

when the only object that can be accessed via the NotesUIWorkspace in this context is this:

ws.CurrentDoc

Yeah, she has a handle to the uiview, but in the context she is sitting in, Notes has no clue what she is asking for because that NotesUIWorkspace has a currentDocument, not a currentView.

That’s at least what I think is happening here.

brandt

Subject: RE: Accessing NotesUIView methods from a form

Nope - because if that were the case, I wouldn’t be able to get the selected documents as a document collection (because there wouldn’t BE any selected documents at that point in the code), and I can.

Subject: RE: Accessing NotesUIView methods from a form

Aren’t you setting the doc collection during your queryOpen event and have it as a global variable? If you set the doc collection there, before the Uiview loses its focus, then you wouldn’t “lose” the doc collection as you opened the form.

Does this app employ framesets? If so, you could always create a page for successful submission and set it to display in the target frame on a successful save. Then your user would have to reopen the view, which would accomplish what you are shooting for.

brandt