Add a program doc to compact Lotus Notes databases automatically
Learn the steps to add a program doc to Lotus Notes users' local public address books to compact large Lotus Notes databases automatically without closing the client.
This tip helps you add a program doc to your Lotus Notes users' local address books to reduce the size of their Notes databases automatically.
![]() |
||||
|
![]() |
|||
![]() |
This is a useful workaround for external salespeople with large local replicas, for example. These users need to simply leave their computers on at night for the doc to compact all of their Lotus Notes databases. This is easier than sending out batch files that require users to sign in and close their Lotus Notes clients.
To get started, follow these steps.
- Create a copy of the pernames.ntf
- Copy the Server\Programs view from your Public Address Book (PAB) template and paste it into the pernames.nsf. Rename this: Programs.
- Copy the Server\Program form from the Public Address Book (PAB) template and paste it into the pernames.nsf. Rename this: Program.
- Create an agent called Program Doc.
- Set the form selection to equal the Program form; the field CmdLine should not contain -A.
- Add this Formula language code to your agent:
- Set the runtime to Agent List Selection, and set it to run on All Documents in Database.
- In the Programs view, add an action called Create Program Doc with a button using the following Formula language code:
- In the "Hide Action When Formula is True", put this code in:
- Finally, replace the design of your PAB with the new template. Instead of seeing pernames.nsf, you should see the new copy of pernames.nsf. Go to the "Programs" view and click on the button. Your program doc is now set to run Compact -B daily at 2 a.m. on your local machine.
Note: The latter is important because if you use local archiving, a program doc is created automatically when you set up local archiving. You can check this initially by opening the hidden view $Programs. If you use local archiving, or have in the past, you will one there showing Compact -A.
tempName := @Name ([ABBREVIATE];@GetProfileField ("directoryprofile";"Owner")); @SetField( "Source" ; tempName ); @SetField( "CmdLine" ; "-B" ); @SetField( "Enabled" ; "1" ); @SetField( "Interval" ; "0" ); @SetField( "Program" ; "Compact" ); @SetField( "Schedule" ; "02:00 AM" ); @SetField( "WeekDays" ; "Sun, Mon, Tue, Wed, Thu, Fri, Sat" ); SELECT @All
Cmd := @DbColumn ("":"ReCache";"":"";"Programs";3); @If(Cmd="-B"; @Return(""); ""); REM {Above code is to prevent the user from creating more than one Compact -B documents and is a back up to the sometimes flaky Hide Action When Formula Is True code}; @Command([Compose]; "Program"); @Command([FileSave]); @Command([CloseWindow]); @Command( [RunAgent] ; "(Program Doc)" ); @Command ([ToolsRefreshAllDocs]); @Command ( [RefreshHideFormulas] ); @MailSend( "yourname@domain.com" ; "" ; "" ; "Compact -B Doc Created" ; "" ; ""); REM {Above is let you know that the user has created the program document}; @Prompt([Ok];"Complete"; "To compact your databases, leave Lotus Notes open during the night. Databases will be compact at 2:00 am your time. This process will recover space on your PC and will increase performance. If you have any questions, contact the Help Desk"); @Command([CloseWindow])
Cmd := @DbColumn("":"ReCache";"": "";"Programs";3); Cmd="-B"
Do you have comments on this tip? Let us know.
This tip was submitted to the SearchDomino.com tip library by member Justin Eiseman. Please let others know how useful it is via the rating scale below. Do you have a useful Lotus Notes, Domino, Workplace or WebSphere tip or code snippet to share? Submit it to our monthly tip contest and you could win a prize.