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.