« Does Local Archiving Work in DWA? | Main| Domino DST for Dummies - Custom Application Edition »

Programmatically Change Save Window State Settings

QuickImage Category   

Although I'd much rather toss a few of my own Lotusphere wrap-up thoughts into the Blogosphere, I figure I'd at least get this one out now while it's fresh in my mind...pretend it's Thursday

My client is going through an upgrade to Notes 7, and one of the great new features is of course the ability to "Save Window State" such that when you restart Notes you see the same window tabs as when you shut down. A fine feature that we decided to turn on by default, but a few users had a problem with this. Specifically, the problem users were those who had, prior to the upgrade, figured out how to add windows to their "Startup" bookmark folder (found under "More Bookmarks"), allowing for instance your Inbox and Calendar to both launch automatically when you started Notes.

The "problem" was that under certain circumstances you might see duplicate window tabs on Notes startup, one for the "saved window state" and the same one again from the"startup". My solution was to give users two buttons so they could pick between the old or new approaches:

- BUTTON 1: Disable the save window state features and continue using the "Startup" option.
- BUTTON 2: Clear out the startup folder in order to rely solely on the newer "Save Window State" approach.

In both cases, the code involved affects the Notes.ini file and the Bookmarks database (bookmark.nsf). While the code isn't particularly complicated, it did take a fair bit of poking around in the design of the bookmarks database to understand what changes were required. Unfortunately the innards of the bookmarks database are not terribly well documented, so I thought I'd share my code here in case anyone found it useful.

Here's the code for BUTTON 1:
Sub Click(Source As Button) Dim ws As New NotesUIWorkspace Dim session As New NotesSession Dim bookmarkdb As NotesDatabase Dim outline As NotesOutline Dim entry As NotesOutlineEntry Dim childentry As NotesOutlineEntry Dim folder As NotesView Dim vec As NotesViewEntryCollection Set bookmarkdb = Session.GetDatabase("", "bookmark.nsf") Set outline = bookmarkdb.GetOutline("UserBookmarkOrder") Set entry = outline.GetFirst() 'This will find and delete the bookmark folder containing the links for the Last State, if they exist Do While Not entry Is Nothing If entry.Label = "Last State" Then Do While entry.HasChildren Set childentry = outline.GetNext(entry) Call outline.RemoveEntry(childentry) Loop Call outline.save() Goto ExitLoop Else Set entry = outline.GetNext(entry) End If Loop ExitLoop: 'Now we need to remove the "link" documents from the Last State folder Set folder = bookmarkdb.GetView("$LastState") Set vec = folder.AllEntries Call vec.RemoveAll(True) 'This will disable the "Save Window State on Exit" user preference Call session.SetEnvironmentVar( "SaveStateOnExit", "0", True) Messagebox "You will need to restart your Notes client for the settings to take effect", 48, "Finished" End Sub
This LotusScript was converted to HTML using the ls2html routine,
provided by Julian Robichaux at nsftools.com.


And here's the code for BUTTON 2:
Sub Click(Source As Button) Dim ws As New NotesUIWorkspace Dim session As New NotesSession Dim bookmarkdb As NotesDatabase Dim outline As NotesOutline Dim entry As NotesOutlineEntry Dim childentry As NotesOutlineEntry Dim folder As NotesView Dim vec As NotesViewEntryCollection Set bookmarkdb = Session.GetDatabase("", "bookmark.nsf") Set outline = bookmarkdb.GetOutline("UserBookmarkOrder") Set entry = outline.GetFirst() 'This will find and delete the bookmark folder containing the links for the Last State, if they exist Do While Not entry Is Nothing If entry.Label = "Startup" Then Do While entry.HasChildren Set childentry = outline.GetNext(entry) Call outline.RemoveEntry(childentry) Loop Call outline.save() Goto ExitLoop Else Set entry = outline.GetNext(entry) End If Loop ExitLoop: 'We need to remove the "link" documents from the Startup folder Set folder = bookmarkdb.GetView("$Startup") Set vec = folder.AllEntries Call vec.RemoveAll(True) 'This will enable the "Save Window State on Exit" user preference Call session.SetEnvironmentVar( "SaveStateOnExit", "1", True) Messagebox "You will need to restart your Notes client for the settings to take effect", 48, "Finished" End Sub
This LotusScript was converted to HTML using the ls2html routine,
provided by Julian Robichaux at nsftools.com.

Your Host

KevinPettitt.jpg
Kevin Pettitt View Kevin Pettitt's profile on LinkedIn

Tools I Use

Idea Jam

Subscribe to This Blog

 Full Posts  Comments

Bloglines Subscribe in Bloglines
Newsgator Subscribe in NewsGator Online
MyYahoo
Google Add to Google
netvibes Add to Netvibes

Contact

Hosted by

OpenNTF

Disclaimer

This site is in no way affiliated, endorsed, sanctioned, supported, nor blessed by Lotus Software nor IBM Corporation, nor any of my past or future clients (although they are welcome to do so). The opinions, theories, facts, etc. presented here are my own and in no way represent any official pronouncement by me on behalf of any other entity.

© 2005-2014 Kevin Pettitt - all rights reserved as listed below.

Creative Commons License
Unless otherwise labeled by its originating author, the content found on this site is made available under the terms of an Attribution / NonCommercial / ShareAlike