Create folder from template view in LS?

Hello to all!

I have one question to you. I need to create folder in LS. It is easy, you have to use db.EnableFolder method. But design of this folder will be created from view or folder whish has property “Default design for new folders and views”. I have such view (viewA) but it is no good. I need to create folder from ANOTHER template view (viewB). This new folder must inherit all columns, and ALL ACTIONS (this is the most important!) from the template view.

In LN Designer 6 Help I didn’t find anything about switch this property “Default design for new folders and views” in NotesView object. I only found read-write property NotesView.IsDefaultView - but it not what I want.

I also tried to create folder through NotesDatabase method CreateView (this method has an argument - TemplateView), but this method create view, not folder. And I can not transform view into folder.

Any ideas?

Thank you for your help,

Michael Halisov

Subject: Create folder from template view in LS ???

I’m sure this is possible, and I’m sure that Stan Rogers knows how. The closest I could get was to grab an existing folder as a document using db.getdocumentbyid, create a new document and do copyallitems, and change the $Name and $TITLE items to the desired folder name. Too bad, though; the new document was a document, not a folder.

Subject: RE: Create folder from template view in LS ???

Your problem was that you were creating a new document and then copying all items. This will create the document as a normal document rather than a folder design element.

Instead, you need to get the existing folder using db.GetDocumentByUNID and then do a doc.CopyToDatabase(db). This will copy everything including the all important $FORMULACLASS item. Then you can change the $NAME and $TITLE items as needed.

Regards,

Roberto

Subject: view to folder

Here’s the code I used to create a folder with the columns from a view: (I am doing this over the web in webquerysave).

Dim s As New notessession

Dim tempdoc As New notesdocument(s.CurrentDatabase)

Set view = s.currentdatabase.GetView("coa")

Call tempdoc.PutInFolder("foa")

Set folder = s.CurrentDatabase.GetView("foa")

Forall c In folder.Columns

	Call folder.RemoveColumn(c)

End Forall

Forall c In view.columns

	Set notesViewColumn = folder.CopyColumn( c )

End Forall

But I can’t make the folder flat if it started out hierarchical.

My quick process overview:

When a certain form is used to make doucments, and when each document gets saved, a folder is made for that documentID. When later documents are saved reference the special documentID, those documents are added to the folder.

Guess what happened:

I wanted the documents I put into the folder to show up, in a flat-non-hierarchical way.

The newly created folder takes the attributes of the Default view in the database. (the one with the blue arrow next to it).

IF I moved a document that has a $REF field in it, I got this error:

Error4005: Notes error: To move a response document to a folder that shows response hierarchy you need to move the topmost parent of the response (folderName)

The default folder had “Show response documents in a hierarchy” selected, and consequently so did the folder. Even when the parent document was already in the folder I still got that error 4005 when a $REF child doc got moved or when some other $REF doc got dropped into the folder, regardless, I got the error.

Despite the error, the documents still got put into the folder I just got that error.

BUT, I did NOT want to see hierarchical viewing of the doucment.

I went into the folder and turned off the “Show responses in a hierarchy”. When I do this with a view the responses behave like normal documents. In the folder, response docs Disappeared.

I went in with LoutsScript and tried to change IsReponse attribute (you can’t. Its read-only. But I don’t always trust the documentation in help).

I next tried to remove the $REF field from the document already in the folder. That document disappeared and never came back. I could make the response documents appear and disappear by toggeling the “Show responses in hierarchy” selection for the folder. If I tampered with the docs in the folder they got dropped from the folder.

Humm,

So I went in and chaned the Default view attributes [ the default view is called (Untitled) when a new blank database is born ]

I turned off “Show responses in hierarchy”, and went back to make new folders.

This time the folder didn’t have the show response thing turned on.

When I tooks documents and PutInFolder, I didn’t get the error for any docs and I could see all the documents in a flat view.

If I manually turn on response hierarch and put a response column in the view, the docs behave like responses.