Thursday, August 25, 2011

Select Records by Date in Views without using @Today or @Now

 When you create your view selection formula and you use @Today or @Now, your view index is constantly updated because those functions are always being changed.  A way to do this and gain some performance on your view selection is to programmatically update your view selection.  Use the below code either in the Initialize subroutine or in an agent that runs once a day to "hard-code" your view selections that depend on dates.
 
      Sub Initialize
         ' This script will update a view selection formula with an actual date versus doing the same thing via the @Today
         ' function (which recalculates constantly.
         ' So you go from:
         ' SELECT ((Form = "FormA") | (Form = "FormB")) & (@Created > @Adjust(@Today;0;0;-60;0;0;0))
         'To:
         'SELECT ((Form = "FormA") |  (Form = "FormB"))  &  (@Created > [06/26/2011])
         ' This should improve the performance of this view since your index is not constatnly being recalculated.
   
         Dim ses As New NotesSession
         Dim db As NotesDatabase
         Dim view As NotesView
         Dim formula As String
         Dim fmDate As  Variant
         Dim dateTime As New NotesDateTime( "" )
   
         Set db = ses.CurrentDatabase
         Set view = db.GetView("myView")
   
         dateTime.LSLocalTime = Now - 60
         fmDate = dateTime.DateOnly
         formula = {SELECT ((Form = "FormA") |  (Form = "FormB"))  & } &{ (@Created > [} &  fmDate & {]);}
         view.SelectionFormula = formula
   
     End Sub


Enjoy!

Monday, August 22, 2011

Return a Domino ArchiveDB to a Mail File

What is the difference between a Domino Archive database and a normal mail file?  Nothing but a profile document.  So, how do you return that status of an archive database to a standard mail file?  Use this script:

     Sub Initialize
       Dim session As New NotesSession
       Dim db As NotesDatabase
       Dim doc As NotesDocument
       Dim item As notesitem

       Set db = session.CurrentDatabase
       Set doc = db.GetProfileDocument("Archive Database Profile")

       If doc Is Nothing Then
          Print "No profile found"
       Else
         Print "Profile found"
         Set item=doc.GetFirstItem("ArchiveDatabase")
       If Not item Is Nothing Then
         Call item.remove
       End If
       End If

       Call doc.Remove( True)
       End Sub


Add this agent to your archive database, run it and your file will be changed back to a normal database after being an archive -- WOW!  Magic!

Remove Domino Database Conflict Documents

Do you have a Domino database that just has tons of conflict documents?  Here's small script that you can add as an agent to help remove those documents.

Create a new agent that is shared and has no target (this will make it run against all documents that you select).  Now, add this code to the Initialize subroutine:

       Sub Initialize
         Const MB_YESNO = 4
         Const ID_YES = 6
         Dim session As New NotesSession
         Dim dc As NotesDocumentCollection
         Dim dt As New NotesDateTime("")
         Set dc = session.CurrentDatabase.Search("@IsAvailable($Conflict)",dt,0)
         If dc.Count > 0 Then
             Dim ans As Variant
             ans = Messagebox ("Search for @IsAvailable($Conflict) found " & dc.Count & " documents. Delete now?", MB_YESNO, "")
             If ans = ID_YES Then
                 dc.RemoveAll True
             End If
         Else
             Messagebox "    No Conflicts found    ",MB_OK,"Not Found     "
         End If
     End Sub


Select this from your agents menu and you will be prompted to remove what conflict documents it finds.  If you happen to be having this issue alot in one of your databases, you may want to research why this is happening so that you don't have to use this type of again often.

Thursday, August 18, 2011

Purge Domino document deletion stubs immediately

How do you purge all document deletion stubs on the Lotus Domino server immediately instead of waiting for the set purge interval?

Deletion stubs in a database can be purged by selecting File --> Replication --> Settings, and entering 0 (zero) days in the "Remove documents not modified in the last" setting. Click OK and close the database. Open the database again to immediately purge the deletion stubs and then change the setting back to 90 days.


IMPORTANT: If you check the "Remove documents not modified in the last" setting and enter "0" in the Days field, all documents will be deleted from the database. DO NOT check this box. Only change the number of days setting to "0". Press the TAB key and as soon as the cursor leaves this field, the purge action executes.