Manage Learn to apply best practices and optimize your operations.

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.

Related resources from
Lotus Notes Domino Database Management Reference Center

Formula Language for Lotus Notes Domino Reference Center

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.

  1. Create a copy of the pernames.ntf
  2. Copy the Server\Programs view from your Public Address Book (PAB) template and paste it into the pernames.nsf. Rename this: Programs.
  3. Copy the Server\Program form from the Public Address Book (PAB) template and paste it into the pernames.nsf. Rename this: Program.
  4. Create an agent called Program Doc.
  5. Set the form selection to equal the Program form; the field CmdLine should not contain -A.
  6. 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.

  7. Add this Formula language code to your agent:
  8. tempName := @Name
    @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 
  9. Set the runtime to Agent List Selection, and set it to run on All Documents in Database.
  10. In the Programs view, add an action called Create Program Doc with a button using the following Formula language code:
  11. Cmd := @DbColumn
    @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( [RunAgent] ; 
    "(Program Doc)" ); 
    ( [RefreshHideFormulas] ); 
    @MailSend( "[email protected]" ; 
    "" ; "" ; "Compact -B Doc Created" ; "" ; ""); 
    REM {Above is let you know that the 
    user has created the program document}; 
    "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"); 
  12. In the "Hide Action When Formula is True", put this code in:
  13. Cmd := @DbColumn("":"ReCache";"":
  14. 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.

Do you have comments on this tip? Let us know.

This tip was submitted to the 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.

Dig Deeper on Lotus Notes Domino Database Management

  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/ community. These cheat ...