LS PutInFolder my solution

Hopefully this will be of help to some, as I have found loadsa and loadsa postings looking for a way to open a folder that has just been created in LS without closing and opening the dB.

After reading most of them and spending a couple of frustrating hours, here is what I have done.

If it does not help you, sorry, if it does happy days.

Dim workspace As New NotesUIWorkspace

Dim session As New NotesSession

Dim dbThis As NotesDatabase

Dim uidbThis As NotesUIDatabase

Set dbThis = session.CurrentDatabase

Call dbthis.EnableFolder( “Why_I_Hate_Notes_Sometimes” )

…… add docs to the folder etc.

Call workspace.OpenDatabase( dbThis.Server, dbThis.Filepath, “”, “”, True, False )

Set uidbThis = workspace.CurrentDatabase

Call uidbThis.OpenView( “Why_I_Hate_Notes_Sometimes”, “”, False, True )

Okay so you end up with the folder open in a new tab on the workspace but it works ……

I found I had to open the database then set the view, using the folder name in the third OpenDatabase parameter caused an error.

Subject: LS PutInFolder my solution

There is actually another way to do this, and although a bit ‘clumsy’ it works like a charm.

Whenever I find the notes client is bahaving ‘funny’ which it often does when it comes to UI-stuff, I tend to revert to the old chained-agents technique.

From your button (or whatever) you call an agent:

@Command([ToolsRunMacro]; “FolderAgentController”)

From within the “FolderAgentController” you call two more agents:

@Command([ToolsRunMacro]; “FolderAgent1”);

@Command([ToolsRunMacro]; “FolderAgent2”)

In the first agent, you create the folder and populate it as you please.

From the second agent, you simply open it.

I know this works, as I recently helped a workmate with this exact problem.

Subject: LS PutInFolder my solution

Okay and here is possibly the simplist solution:

In designer create a folder (in this example cunningly named Folder) which is private on first use.

Here is the code

Sub Initialize

Dim workspace As New NotesUIWorkspace

Dim session As New NotesSession	

Dim uidbThis As NotesUIDatabase

Dim vwFolder As NotesView

Dim vwSource As NotesView

Dim vecAll As NotesViewEntryCollection

Dim docSource As NotesDocument



Set uidbThis = workspace.CurrentDatabase

Call uidbThis.OpenView( "Folder" )



Set vwFolder = workspace.CurrentView.View

Set vecAll = vwFolder.AllEntries

Call vecAll.RemoveAllFromFolder( "Folder" )



Set vwSource = session.CurrentDatabase.GetView( "SourceView" )

Set docSource = vwSource.GetFirstDocument

While Not( docSource  Is Nothing )

	Call docSource.PutInFolder( "Folder", False )

	Set docSource = vwSource.GetNextDocument( docSource )

Wend

End Sub

The only reservation I have here is the private folder will not be visible in the designer post it’s creation to anyone but it’s creator. If that is not an issue lovely.