Can I generate a view dynamically?

Hi All,

I am wondering can I create a view in script like

dim vw as NotesView

vw.SelectionFormula = “Select @All”

However I can not get the view to initialize.

keep in mind this view does not exist under ‘Views’ in the designer client. I want to create, use and delete the view all in script under the covers.

Is this possible? Nothing in the designer client or the forum seems to touch on this aspect of a view.

Thanks for any feedback.

Shawn

Subject: Can I generate a view dynamically??

I don’t think you can with native lotuscript but probably using the CAPI. An option might be to use a folder vs. a view.

If you use this:

Call notesDocument.PutInFolder( folderName$ [, createonfail ] )

It creates a folder if it does not exist basing the folder design on the default view in the database. You might be able to leverage this.

What exactly are you trying to accomplish?

Subject: Can I generate a view dynamically??

Thanks for the feedback folks!

Much Appreciated.

Shawn

Subject: Can I generate a view dynamically??

Yes - see the NotesDatabase.CreateView method.

From Designer Help:

Creates a view.

Note This method is new with Release 6.

Defined in NotesDatabase

Syntax:

Set notesView = notesDatabase.CreateView( [ viewName$ ] , [ viewSelectionFormula$ ] , [ templateView ] , [ prohibitDesignRefreshModifications ] )

Parameters:

viewName$

String. Optional. A name for the view. Defaults to the “(untitled)” view. The view is created even if this name duplicates an existing view.

viewSelectionFormula$

String. Optional. A selection formula. Defaults to either:

The selection formula of the template view.

“SELECT @All” if no template view exists.

If specified, this formula overrides the selection formula of the template view.

templateView

NotesView. Optional. An existing view from which the new view is copied. Defaults to either:

The view checked as “Default design for new folders and views” in the database.

None if no view in the database is specified as the default design.

prohibitDesignRefreshModifications

Boolean. Optional.

True (default) prohibits the view design from being refreshed.

False allows the view design to be refreshed.

Return value

notesView

The new view.

Usage

If no template view exists, the new view contains one column with “@DocNumber” as its value.

Subject: RE: Can I generate a view dynamically??

Forgot about that one. Have been working with so many differnet versions of notes (R4, 5 6 and 7) - its hard to keep up with all the new methods and properties.

Subject: RE: Can I generate a view dynamically??

If you genuinely want to create a new view that isnt based on an existing one, you might want to look at creating the DXL and importing that. Just hunt in help for DXL.

Simon