< Back

Document Subject: Add certain docs to folder depending on date
Hint Short Cut: Add this to your code & documentation to help you find this page.
http://#ArchiveToFolder or http://A555F9/nn.nsf/ByAlias/ArchiveToFolder
This is a bit of code that moves documents rejected before a certain date into a folder.

Put this into a button:

Dim s As New notessession
Dim db As notesdatabase

Set db = s.currentdatabase

defdate = s.getenvironmentstring("eDefDate")
deffolder = s.getenvironmentstring("eDefFolder")

If defdate="" Then defdate = Cstr(Today)
If deffolder="" Then deffolder = "RejectedAgesAgo"


d= Inputbox$("What date should they be created before?", "Date", defdate)
f=Inputbox$("What folder should they be put in?","Folder", deffolder)

Call s.setenvironmentvar("EDefDate", d)
Call s.setenvironmentvar("EDefFolder", f)

Dim col As notesdocumentcollection
Set col = db.ftsearch("",20)

Set SearchDate = New NotesDateTime("01/10/1999")

Selection = "Form = ""F1"" & Date1 <= @Adjust(" & d & ";0;0;0;0;0;0)"
Selection = "Form = ""F1"" & Date1 <= [" & d & "]"
Print Selection

Set Col = DB.Search(Selection, SearchDate, 0)
If Col.Count = 0 Then
Print "none found"
Else
Call col.putallinfolder(f)
Print "moved " & col.count
End If

Note a new folder is not shown on the folders view until the database is closed

and reopened. If you know a way aroud this let me know!