Deleting Private Views In Script

Have a DB that died on one prod server but is running okay on the other. In Log it is showing as 24 gigs in size, when create a new copy drops down to about 4 gigs and since failur have not been able to get views to index and back into it. So only 1 working copy on prod. In looking under DB Usage shows a bunch of private views in there. Have looked under here and tried a couple script examples to search all views and remove those private ones. When running this as a menu selection agent from the client on the server it is not finding them however.

Here is agent:

Sub Initialize

Dim session As New NotesSession

Dim ws As New NotesUIWorkspace

Dim db As NotesDatabase

Dim view As NotesView

Dim varAnswer As Variant

Dim readers As Variant

Set db = session.CurrentDatabase

Forall v In db.Views

If v.IsPrivate Then

Messagebox "View " + Cstr(v.Name) + " is private."

Set view = db.GetView(Cstr(v.Name))

readers = view.Readers  

varAnswer = ws.Prompt(PROMPT_YESNO,"Remove

  Private View", "Do you want to remove this private

  view?")

If askme = 1 Then

 If view.Readers(0) = session.Username Then

  view.Remove 

  Messagebox "Private View Removed from Server"

 End If

End If

End If

End Forall

End Sub

What I am looking to do is run some process script or otherwise that will find all the private views that are on the server and remove them. I realize any private views that are in the desktop.dsk will not be found, but I assume that if they are showing up in the db in the log file that they are on the server.

Thanks in advance,

Steven Cannon

JB Hunt Trucking

Subject: Deleting Private Views In Script

Suggestions:

Have you tried purging the views in the Admin client ?

Can you run the agent w/ full access admin rights?

What about compact with -D to discard all the view indexes.

Subject: RE: Deleting Private Views In Script

Have ran compact -d and that did not work, and cannot see the private views in the Admin client, but they continue to show up in the log file. Agent is set to setting 3 for full rights and ran it from menu list when logged into the client on the server with the server ID file. Right now DB is 24 gig in size with only 330k documents in it, with no real attachments in the documents. When create a new copy with all documents it takes about 3.5 hours to do so, and reduces it down to about 4.5 gig in size. When start indexing all the views it has just run forever and not stopped. When we look in log at view index sizes and add that to the 4.5 gig that takes us up to about 15 gig in size. So about 8-9 gig that would seem to be just the documents, which does not add up when they are only about 10-12 k in size. So as you may gues, since this is a DB we bill our customers from it is rather hair pulling at this point, just crossing our fingers hoping nothing goes wrong with the one remaining copy for about 60 days why 2005 billing is finished up. We have created a brand new copy of the DB with no docs for 2006 and that one seems to work just fine, and we removed the ability to create personal/private views and for 6 days now is running fine. They put about 14k documents in there monthly.

Thanks for the suggestions.

Steven

Subject: Deleting Private Views In Script

Not sure if this is it, but I see two things

  1. you reference a variable called “askme” in an IF clause but it’s not assigned any values. Looks like it should reference “varAnswer”??

  2. do you really need to check the view.Readers against the session.Username? Don’t you just want to delete it?

I realize that if the private view isn’t found then the above won’t matter…

Maybe it will help anyway.

Joe

Subject: RE: Deleting Private Views In Script

Joe,

Yep caught that typo from pasted code on prod and changed it pasted in from dev and did not update it, my bad. But when fixed to be varAnswer it did not find any private views in production yet there are 12 views list under Log file in DB Usage by size. Those are the 12 we are trying to delete without having to attempt another recreate or create from scratch and move all documents as there are billing authorization mails that have been sent out on about 15000 documents with doc links in them that would have to be resent. But if we cannot solve this and any issues appear that right now is our only option. So trying to see if we can clean this thing up before problems. For #2 I got that piece of code from another post from today (I think) about private views and thought it might be helpful. But no I think it would work if just did view.remove if it find any private views, which it is not right now.

Thanks,

Steven

Subject: RE: Deleting Private Views In Script

Hi Gregg Young, Steve & Others,

There are some issues if one uses ‘getView’ method to get a “private or shared private on first use views”.

So better to loop thru all view names of database, get the private view and then remove it. You can use the following, snippet in the QueryClose event of the Database Script so that whenever user is out of the database, it searches for the private views and removes them from database.

Forall v In db.Views

If v.IsPrivate Then

readers = v.Readers

If Isarray(readers) Then

If Ubound(readers) < 1 Then

If readers(Lbound(readers)) = session.Username Then 'private view on server

v.Remove

End If

End If

End If

End If

End Forall

Subject: RE: Deleting Private Views In Script

Tried this is a test situation. Created a DB then opened it in client and created a private view called Steven. When I click View goto it opens the view with a few documents in it. When I exit the database the script executes just fine. When I open the DB in design it still shows the private view Steven but when I attempt to open it, I get the message Document has been deleted. When I just hit the delete key asks me if want to delete the private view Steven click yes, it does not go away. Also if I go back into the client and click View Goto still shows the view Steven, but if I try and switch to it it opens the view that precedes it in the list as if the view Steven was not a valid option. But generates no error message.

So I can only assume that this QueryClose script does in fact delete the private view (if it was created by me), but it does nothing to clean up the view list or the views listing in design so that it stops appearing. An admin created a private view called Tina which I cannot see in View Goto or in Design an the script does not delete it when running for me, which would make sense based on code. So why do I need to check names, why can I not just delete all private views and why does the script not clean up the design or the View Goto Listing?

Thanks,

Steven

Subject: RE: Deleting Private Views In Script

Access the view in designer and check properties for just nowMake sure the view index properties options are as Refresh —> Automatic and Discard ----> After each use

Try this way and test it again. Cache or Index problems might get fixed.

Here you go:

Remove the desktop icon.

Pull it back again from server, if on server, on to the workspace.

Then test it again, the way you tested. This may solve your problem. I have no problem in my application. Once or twice got a problem, followed above steps which solved my problem here with the private views.

Subject: RE: Deleting Private Views In Script

I think the desktop contains a “pointer” to known private views. You could probably just remove the icon from the workspace and it’ll go away. Come to think of it, removing the icon from the desktop may remove the private views too. I know it does if they’re stored in the desktop but I’m not sure if it will in this case (since they’re stored on the server). It’s a low-tech solution, but it might be worth a try.

I’d probably just blow away the private views (as you suggested). It should be easy to do with the NotesNoteCollection class as Andre mentioned. Since you know the names of the private views to be deleted, you could also just look for them by name. See here → for an example that could be modified to fit your situation.

hth,

dgg

Subject: RE: Deleting Private Views In Script

Except that every time you get a view from NotesDatabase.Views, it updates the view index for that view. The questioner already said that indexing all the views doesn’t terminate in a reasonable period of time. A NotesNoteCollection would be a better option to getting all the private views; they can just use the SelectionFormula property to restrict the selection to private views only, then load the design note as a NotesDocument and delete it.

Subject: Deleting Private Views In Script

I am having the same issue. I look forward to seeing if anyone has a suggestion to this problem

Subject: Deleting Private Views In Script

None of the regular views in this DB are Private on First Use so these have all been created by users as private (their access has been changed to not allow that any longer)

Subject: Thanks all for suggestions…now I have to test them.

Thank you all for the many suggestions here. I have a few to go through and test. When I get through them (on call this week) probably next week and determine if 1 seems to work better than the rest or the general results of the ideas I will post the results back here so that others can review and comment on them or use them later on.

Thanks again for all the ideas.

Steven