Solved

Archive old documents from a production database.

Posted on 2004-09-21
26
328 Views
Last Modified: 2013-12-18
Hello all experts,

Let me briefly explain what I have here.
I have a production database on a server which contains documents ranging from year 2001 to 2004 and more.
What I need to do now is archive the documents that are not of the current year(2004) into another database(archive_year.nsf) and delete the archived documents from the production database.
I am not the server administrator.
Can somebody please tell me what would the server administrator need to do for this archiving? Will he need to create a new empty database then have someone code an agent to run on the production server that will select the documents and copy it to the new database?
Or are there some other steps? I need detailed step-by-step instructions if possible as I need to do a documentation on this. Thanks for the help and let me know if more details are needed.
0
Comment
Question by:SadCase
  • 13
  • 11
  • 2
26 Comments
 
LVL 19

Accepted Solution

by:
madheeswar earned 100 total points
ID: 12119903
First Create a view with  a selection forumla: View Name: uploadview
Select Form="yourFormname" & @Year(@Created)!=@year(@today)

The above will display documents which are not creatd in 2004.

Now, create an agent:
Agent Name: UploadDocs
Select Lotus Script

Sub Intialize
Dim ss as new notessession
dim db as notesdatabase
dim view as notesview
dim doc as notesdocument
dim updoc as notesdocument
dim updb as notesdatabase

set db=ss.currentdatabase
set view=db.getview("uploadview")
set doc=view.getfirstdocument
set updb=ss.getdatabase(db.server,"archive_year.nsf")
while not doc is nothing
set updoc=updb.createdocument
Call doc.CopyAllItems( updoc )
call updoc.save(true,true)
set doc=view.getnextdocument(doc)
wend
End sub


Copy a new database on the server from the database and name it as archive_year.nsf
0
 
LVL 19

Expert Comment

by:madheeswar
ID: 12119941
Once the above is Run, then run the below agent to delete docs. Ofcourse we can delete docs from above code. To simplify things I am creating anotehr agent to delete docs.

NOTE: PLEASE CREATE A BACKUP COPY BEFORE YOU RUN THE ABOVE AGENT .

Sub Click(Source As Button)
      Dim notesuiworkspace
      Dim uidoc As notesuidocument
      Dim session As New NotesSession
      Dim db As NotesDatabase
      
      Dim view As NotesView
      Dim doc As NotesDocument
      Dim doc1 As NotesDocument
      
      Set db = session.CurrentDatabase
      Set view=db.GetView("uploadview")
      
      If Not view Is Nothing Then
            Set doc=view.GetFirstDocument
      'Remove existing search Results from the personal folder
            While Not doc Is Nothing
                  Set doc1=view.GetfirstDocument
                                                Call doc1.remove(True)
                  'Call doc1.Removefromfolder("uploadview")
                  Set doc=view.GetNextDocument(doc1)
            Wend
      End If
      
            
End Sub
0
 

Author Comment

by:SadCase
ID: 12120095
Hmm...... I need the archive database to be functioning like the production database except that it would have old documents while the production database contains the current year document.
Because after archiving the documents, I still need to create additional forms and views on the archive database so that the documents can still be accessed from the web(only difference is that now it resides in another database).
Reason why I'm needing to archive is so that the production server will be more efficient(only containing current year documents).
I'm guessing I will need to create a new copy of the database and choose copy design elements only?

Sorry for not being clearer in my question.
0
 

Author Comment

by:SadCase
ID: 12120116
I have many different forms and views in the production database and if I make a new copy of it with design elements intact, will I need to create agents to copy the documents to the different forms and views?
0
 
LVL 19

Expert Comment

by:madheeswar
ID: 12120174
just run the above agents from the production database and it will take care.
Creating a new copy with design elements is fine.


or you can schedule the above agents to run daily. And the first Agent at 1AM and the second agent at 3AM daily.
0
 

Author Comment

by:SadCase
ID: 12120399
Hi madheeswar,

I tried running the UploadDocs script but I keep getting a "archive_year.nsf database is not opened" error. I think its because the archive_year.nsf database resides in the local computer. Its not on the same server as the production database. Is there anyway to change the code so that it will copy to a database on the local drive?

Thanks
0
 
LVL 19

Expert Comment

by:madheeswar
ID: 12120412
Instead of this:
set updb=ss.getdatabase(db.server,"archive_year.nsf")

use:
set updb=ss.getdatabase("","archive_year.nsf") 'This local database should reside on Notes data directory.
0
 

Author Comment

by:SadCase
ID: 12120562
Hi Madheeswar,

I ran the script but nothing seem to have been copied over.
Started running agent 'UploadDocs' on 09/22/2004 03:33:08 PM
Running on all documents in database: 4380 total
Found 4380 document(s) that match search criteria
Ran LotusScript code
Done running agent 'UploadDocs' on 09/22/2004 03:34:24 PM

For the view, I changed the selection formula to :
SELECT @Contains(ID;"ABC123") & (Date < [01/01/2004]) where Date and ID are fields. Right now, there's only one column in the view with the header #
I changed the formula because the production database I am using right now is basically a copy of the actual production so I wasnt sure if the @Created date will be correct.
0
 

Author Comment

by:SadCase
ID: 12120577
I also did not specify the form in the view selection formula. I need to copy all documents from all forms/views that matches the Date<1/1/2004 criteria over to the archive database.
0
 
LVL 19

Expert Comment

by:madheeswar
ID: 12120582
is the view displaying any documents?

And enable Lotus Script debug and look in the loop. It should come into the loop.
0
 

Author Comment

by:SadCase
ID: 12120661
The view only has a single column # and it contains numbers from 1 to 1654(1654 documents that match the SELECT @Contains(ID;"ABC123") & (Date < [01/01/2004])  condition i think)
I have no idea how to use the debugger to check whether the code went into the loop but when I clicked continue, the debugger didnt go to any line and stop it just completes running but no documents are copied.
The matches done by the agent is wrong too because it found 4380 documents which is all the documents in the database.
Could this be due to the agent restriction set to 1 ?
0
 
LVL 19

Expert Comment

by:madheeswar
ID: 12120690
To enable Debugger:
File->Tools->DebugLotusScript

and don't click on Continue. click on StepNext
or Place this line in between the loop :
k=k+1
Print "Processing: " & cstr(k)

And before loop:
k=0

U can see the Processing and no in the status bar of Notes client.
0
 
LVL 19

Expert Comment

by:madheeswar
ID: 12120697
And to confirm, make this type of selection formula:
Since it is a etsting environment:

Select Form="Formname"

this will display all the docs. Then run the agent.
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:SadCase
ID: 12120774
OK this time I used the Debugger when running the agent and clicked "Step Into" instead of Continue. The code goes down line by line then keeps on looping in the while loop but nothing gets created.

The match is still 4380 so I went to the agent's Document selection formula window and added 2 conditions, both conditions by field:
Date is before 01/01/2004 AND field ID contains ABC123
After I added this, the agent matches becomes 1654 which is the same as the view but nothing is copied
0
 

Author Comment

by:SadCase
ID: 12120813
When i add Select Form="Formname" in the view's selection formula it becomes empty.
0
 
LVL 19

Expert Comment

by:madheeswar
ID: 12120823
What is the status bar displaying?
did u kept my Print statements as I said?
0
 
LVL 19

Expert Comment

by:madheeswar
ID: 12120828
Selectin formula should be:

Select Form="AnyofYourFormName"
0
 
LVL 19

Expert Comment

by:madheeswar
ID: 12120869
Just now found a good code from Qwaletee:
Dim s as new notesSession

Dim source as notesDatabase
Set source = s.currentDatabase

Dim documents as notesDocumentCollection
Set documents = source.unprocessedDocuments

Dim document as notesDocument
Set document = documents.getFirstDocument

Const LOCAL = ""
Dim destination as new notesDatabase ( LOCAL , "DESTINATION.NSF" )

Do Until document is nothing
  document.copyToDatabase destination
  set document = documents.getNextDocument ( document )
Loop

the above code is to copy to destinatin db.
Follow the URL:
http://www.experts-exchange.com/Applications/Email/Lotus_Notes_Domino/Q_20916805.html
0
 

Author Comment

by:SadCase
ID: 12120979
Hi Madheeswar,

with your print code, the status bar prints Processing : 1 2 3 and so on while lopping but still, nothing gets copied. When I tried Qwaletee's code, nothing gets copied too.
0
 
LVL 19

Expert Comment

by:madheeswar
ID: 12120999
then it is copying perfectly to the archive database.
check the archive_year.nsf

and try this modified code from Q:
Dim s As New notessession
      Dim source As notesDatabase
      Set source = s.currentDatabase
      Dim view As notesview
      Dim document As notesDocument
      Set view=source.GetView("Uploadview")
      Set document =view.getFirstDocument
      
      Const LOCAL = ""
      Dim destination As New notesDatabase ( LOCAL , "archive_year.NSF" )
      k=0
      Do Until document Is Nothing
            k=k+1
            Print "Processing: "&Cstr(k)
            document.copyToDatabase destination
            Set document = view.getNextDocument ( document )
      Loop


0
 

Author Comment

by:SadCase
ID: 12121076
Hi Madheeswar,

I gotta leave for now will get back to you in 15 hours' time. By the way I realised the documents were indeed copied correctly, silly me. I was looking in the view which contained only 2004 documents no wonder I kept seeing nothing.
0
 

Expert Comment

by:lianaizhouzhiruo
ID: 12139143
oK, let's see if I got this correct.
To create an archive database from my production one, I need to first:
1 Get the server administrator to create a new copy of the database and copy design elements only.
2 Delete unneeded forms and views from this new Archive database.
3 Create an agent that will copy all documents that meets a specified criteria over from the Production to the archive. Your code does that but I realised there was a simpler way to do it without needing lotusscript or creating a new view. Just create an agent in the Production with simple actions and it will do the same thing as your code although LS seems to be faster.
4 After copying the documents over to the Archive, create an agent that will delete away the copied documents from the Production. This can also be done with an agent that uses simple action.
5 Final step would be to create new forms and views for users to view documents in this Archive database.

Are the above steps correct? Am I missing something?
0
 
LVL 19

Expert Comment

by:madheeswar
ID: 12140283
lianaizhouzhiruo ,
to whom you are refering the steps?

I think SadCase got what he/she looking.

question is closed.

If u have simple solution, please provide it with steps(including agents) and take the above points.
0
 

Expert Comment

by:lianaizhouzhiruo
ID: 12140342
RE: Madheeswar

Just summing things up. I dont expect to get points for that :) You got SadCase through since the start. Points' all yours
0
 
LVL 19

Expert Comment

by:madheeswar
ID: 12140364
lianaizhouzhiruo,
THEN i WILL CORRECT YOUR STEPS.
1 Get the server administrator to create a new copy of the database and copy design elements only.
>> if the user have rights, then no need to contact admin. Else the above step applies.
2 Delete unneeded forms and views from this new Archive database.
>> If it is an archive database, it means, everything will be in tact. Including views, forms. even maintaing unneeded views doesn't create much problem. so, I will exclude this point.
3 Create an agent that will copy all documents that meets a specified criteria over from the Production to the archive. Your code does that but I realised there was a simpler way to do it without needing lotusscript or creating a new view. Just create an agent in the Production with simple actions and it will do the same thing as your code although LS seems to be faster.
>> My idea of writing LS is to provide faster solution. Ofcourse Simple Actions will be faster compared to LS(According to documentation).
4 After copying the documents over to the Archive, create an agent that will delete away the copied documents from the Production. This can also be done with an agent that uses simple action.
>> Yes.
5 Final step would be to create new forms and views for users to view documents in this Archive database.
>>it depends on user requirement. If they want same look and feel, then no need to change or create new design elements in Archive copy.

Thats it.
0
 

Author Comment

by:SadCase
ID: 12140741
Hi,

Thanks Madhesswar for help and lianaizhouzhiruo for summary. I think the last 4 posts just about solve my question! Thanks to both of you and madheeswar gets an extra something called points lol
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now