Dynamic Outlines & Views - (Im)possible?

The user requirement was for one form in which a category was selected to which the rest of the data related. The documents created with this form then wanted to be viewed via separate menu options/views. Easy enough if you’ve got a fixed number of named categories but the user wanted to be able to add more categories (max 20) if required via an ‘Admin’ form.

I created an outline with 20 entries to automatically show all categories the user had entered. This was easy enough, as the Outline titles shown are programmable as are the hide properties, but what to show as the source? In the end I chose a view, creating 20 of those, identical apart from the Initialize script which would each find it’s own document category to display (Nth entry from the admin list) and then alter the selection formula via a runonserver agent (had to be done this way as normal user wouldn’t have appropriate level of access in ACL):

Set db = session.CurrentDatabase

Set vwlookup = db.getview(“vwListCategories”)

Set Entrycoll = vwlookup.AllEntries

If Entrycoll.count > 0 Then

Set ViewEntry = Entrycoll.GetNthEntry(1)

If ViewEntry Is Nothing Then

category = ""

Else

	Set CategoryDoc = ViewEntry.Document

	category = CategoryDoc.Category(0)

End If

Else

category = ""

End If

formula = |SELECT Form = “Main Document” & Category =“| & category & |”|

Set DummyDoc = New NotesDocument(uiw.CurrentDatabase.Database)

DummyDoc.Form = “Dummy”

DummyDoc.Formula = formula

DummyDoc.ViewName = “List Category 1”

Call DummyDoc.Save(True,False)

Set agent = uiw.CurrentDatabase.Database.GetAgent(“Modify View Selection Formula”)

If Not Agent Is Nothing Then

If agent.runonserver(DummyDoc.noteid) = 0 Then

	

End If

End If

OK? So far so good. Now for the problem, getting Notes to refresh the view once you’ve altered the selection formula. In the QueryOpen event of the view Notes was still referring to the view you were currently in, not the view the outline you had just clicked on was going to send you to, so in the PostOpen event of the views I had this:

Dim uiw As New NotesUIWorkspace

Dim uiview As NotesUIView

Dim vwview As NotesView

Set uiview = uiw.CurrentView

Set vwview = uiview.View

Call vwview.Refresh

Call uiw.ViewRebuild

Call Source.View.Refresh

Call uiw.ViewRefresh

Great, that works, apart from ViewRebuild can’t be done for access levels less than Designer so in the real world the user gets an error. Remove that and ViewRefresh may refresh the view but it doesn’t change the contents! If you click on another outline/view and then come back then fine, but not very good from a UI point of view.

Any ideas anyone as this is so close to working or am I trying to do something that is just too flexible from a Notes point of view?

Subject: Use an embedded single category view