Problems with OpenView. Please Help- Very Urgent

Hi to everyone.

We had a requirment for making a search screen, on clicking the generate report Action on the form, A dynamic view is created with the selection criterion embedded in the Selection Formula of the view.

– We take values from the Form

– Create a Selection Criterion - String querystring

– Generate a new view using CreateView - NotesView

– Then Open the view using OpenView

Now we are Ok till the 3rd point. The view is generated. But when we do the OpenView command, It gives an Error Message Saying that the View does not exist. Here is the code.

newviewname = Trim(“delete” + Cstr(Round((8999 * Rnd + 1000),-2)) + Cstr(Hour(Now))+Cstr(Minute(Now))+Cstr(Second(Now)))

'Formula that will apply in the New created View

myviewformula = |SELECT Form = “Project_information” | & querystring

'Create new view with name from user input

Set UsersView = s.CurrentDatabase.CreateView(newviewname,myviewformula,view)

----Then to open the view we do this.----

Set ws = New NotesUIWorkspace

Call ws.ViewRefresh

Set udb = ws.GetCurrentDatabase

Call udb.OpenView(newviewname, , False,True)

The Problem is that sometime this code works and some time it doesnt work. It gives an error saying that the view not found. Please Help in this situation.

Regards,

Jawad Rana.

Subject: Problems with OpenView. Solution

I seem to remember that dynamically creating a view has the caveat that the database must be closed and reopened before it is available for use.

Instead, I would recommend using folders. What you do is have a template folder to base new ones from. When a user creates a view, you have a function that copies the folder to a new name, with the username being part of it. You can then programmatically set the readers as the user himself and the administrator and redirect the user there.

Of course, you would have to perform searches and put documents in the folder, but it’s a lot more flexible and creates less work on the server in the long run. Every view added to the database add overhead and folders are cheap since they don’t require updating by the server.

For instructions on how to do this, search the KnowledgeBase for folders and how to work around private folders not working on the web. There is a lot of code to help you out.

Cheers

Subject: RE: Problems with OpenView. Solution

Jeffery thanks for the solution and i do agree with you on this. As per the latest research we have found that if we keep the designer open with the lotus notes client, only then it open the views and in any other scenario it doesnt open the view. Now One last favour i want is to know that can you please give me any URL where i can find the code for creating Folders and putting all documents from a view into a folder.

Thanks in advance.

Regards,

Jawad Rana

Subject: RE: Problems with OpenView. Solution

If you search here, you will answers to all kinds of problems you never knew you had.

Enjoy…

-Jeff

http://www-3.ibm.com/software/lotus/support

Subject: Problems with OpenView. Solution

The views are created each and every time, but Notes doesn’t recognise them. This is probably down to a lack of synchornisation between the NotesUIDatabase and NotesDatabase objects. I imagine you need to get a new handle on the NotesDatabas eobject for the code to work flawlessly.