Changing the default view by script

Howdy! :wink:

I’m making a tiny script to make sure that the default views are set properly each night. There are a lot of agents, and templates, etc. that work on each db each night, so I’m doing this to make sure the defaults are ok. Here’s the script:

dim ns as New NotesSession

dim db as NotesDatabase

dim nv_Def as NotesView

Set db = ns.CurrentDatabase

Set nv_Def = db.GetView(“DefaultView”)

’ if it’s already set then end

if nv_Def.IsDefaultView then exit sub

’ make sure no others are set

Forall nv in db.Views

if nv.IsDefaultView then

nv.IsDefaultView = false

Exit Forall

End If

End Forall

’ set the good one as default

nv_Def.IsDefaultView = true

End Sub

Basically, when the proper one is the default view, the script ends at the beginning, as it’s supposed to. If another one is the default, the forall unselects it, and sets the default one, no problem.

The problem occurs when there is no default view selected! In the debugger, the “nv_Def” view is set properly, but the “nv_Def.IsDefaultView = true” doesn’t do anything.

Any ideas or hints would be welcome.

Thanks, in advance!

Steve in Montreal :wink:

P.S. As a wishlist, why can’t we set a view like this:

Set nv_Def = db.DefaultView

“I don’t suffer from insanity. I’m enjoying every minute of it.”

Subject: SOLVED! Changing the default view by script

Howdy!

I checked in the Technotes, and found the answer. =8(

http://www-1.ibm.com/support/docview.wss?rs=0&q1=isdefaultview&uid=swg1LO07290&loc=en_US&cs=utf-8&cc=us&lang=en

Take care!

Steve in Montreal

“It hurts to be on the cutting edge.”