Bruce Elgort

If you haven't yet tried Trigger Happy...
Wednesday, April 20th, 2005
Back in February, Damien Katz of former IBM/Lotus fame wrote an amazing utility for Lotus Notes and Domino that hasn't gotten the press that I think it really deserves. Let me give you a brief tour of "Trigger Happy" and how it works and then maybe you realize the true power that this OpenNTF application offers.

Trigger Happy originally called "AgentBoost", is a Domino server addin that can monitor events in your Notes and Domino databases that can be configured to run an agent on the server before or after the event you specify occurs. Database events include modifying or saving a document, opening a document, opening a database, deleting a document or receiving mail in mail.box.

There are two components that you will need to setup in order to use Trigger Happy. The first is the ntrigger.dll which needs to be installed on the server and the second is the creation of the TriggerHappy.nsf file on the server. Instructions on how to setup these two components is provided in the database template.

The best way to get started with Trigger Happy is to install the sample agent (developed by Julian Robichaux) that Damien provides in the template in your favorite development database. The "Example: Log Document Changes" agent will print out to the Domino console any fields that have changed in a document. Pretty simple yet powerful example.

Let's take a look at the setup screen for the trigger in the TriggerHappy database:

Trigger Happy configuration


To start I selected the database that contains the sample agent. Next is to select the agent that want to have run on the event you select from the dialog box. The next thing you will need to do is to let TriggerHappy know when it should run the agent - "Before" or "After" the event occurs. Are you still with me? Next thing to do is to select the event you want the agent to fire upon. For this example I have selected when "A document is modified or saved". The next step is to tell which database to monitor. The two options you have are for the database you selected above or to have it run on all databases on the system. BE CAREFUL selecting this option. If you select every database on the system Trigger Happy can seriously affect the performance and stability of your server since it will be triggered for every modified or saved document. As you can see I have told Trigger Happy to run in the database where the agent is. The next thing we need to do is to identify which documents in the database need to be monitored. The two options are "data documents" and/or "design documents". For this example I have selected data documents. And to top it off you can even include a formula that if true will include only specific documents.

So now that I have setup my trigger I can see on the server that Trigger Happy knows that I have created a trigger:

Trigger Happy detects a new trigger


So now we are ready to go. I am now going to hop over to my playground.nsf database and modify a record in the database.

Trigger Happy output on the Domino console


Well golly-gee, look at that. Trigger Happy executed the agent as soon as I saved the document in my database. Take a look in the above figure and notice that I was able to catch the old and new values of field1 and field2. Has it clicked yet? Do you realize how powerful this great application is? In a production application you may want to record the field changes to a central database or to an external SQL database or do anything else for that matter. Heck you may even want to integrate Trigger Happy with Julian's' OpenLog database.

If you haven't yet downloaded Trigger Happy may I suggest at this time that you add it to your To Do list. May I also suggest that you provide any feedback you may have via the OpenNTF site. Damien is very interested in your feedback. If you have any suggestions or ideas on how Trigger Happy can be used please feel free to leave feedback here or on the OpenNTF site.

You can download Trigger Happy here.



 
Comments

Comment posted by Julian Robichaux04/21/2005 02:31:07 PM
Homepage: http://www.nsftools.com


Good entry. You're right, a lot of people have trouble understanding exactly what TriggerHappy can do for them. Some potential examples I've thought of:

1. Tracking all changes to the Name and Address Book (the auditors will love you for that)
2. Tracking who changes design elements in one or several databases, and when the changes happen (again, good for auditing if nothing else)
3. Tracking who reads documents in a database (there's an event for "After a document is opened")

My ideas tend to be auditing-related for some reason, although you can do some neat things around modifying docs as well. In fact, if you have an agent set to run before a doc is saved, you can even use Trigger Happy to cancel saving the changes if certain conditions are met.

Also, you don't have to run it on the server. You can run it on a workstation as well, which makes it easy to play around with. If you use the example agent locally, it will just log to your local log.nsf file, and it'll work just like it would on the server.

If you're looking for the "quick local install" version of the instructions, here you go:

1. Download the TriggerHappy zip file from OpenNTF. From the zip file, copy the "ntrigger.dll" file to your Notes program directory, and the "TriggerHappy.ntf" database to your Notes data directory.

2. Create a new database (File - Database - New) in the root of your data directory called "TriggerHappy.nsf", based on the "Trigger Happy Configuration (6)" template. The database must be called "TriggerHappy.nsf" and it must be in the root data directory (not a subfolder).

3. Modify the EXTMGR_ADDINS line in your Notes.ini file to include "trigger.dll" (for example: EXTMGR_ADDINS=DDocNPwd,trigger.dll).

4. Restart your Notes client.

5. Copy both the example agent ("Example: Log Document Changes") and the script library ("Trigger Happy") from TriggerHappy.nsf to another database.

6. Create and save the Trigger Happy Config doc as you described in the screenshot above.

7. Wait 30 seconds or so (for the Trigger Happy manager to pick up the new config doc) and create or modify a document in the database you used in step 5 and 6.

8. After you've saved the new/modified doc, open your local log.nsf file and look at the most recent log document in the "Miscellaneous Events" view (which is the default view for that database). You'll see a change log similar to your server console screen shots.

Two nice things about the example agent: (A) it's very generic, so it should work on any database, and (B) if you want to log to a database instead of the log.nsf file, all you have to do is modify the "Logger" class.



Comment posted by Slawek 04/21/2005 06:11:35 PM


other uses I thought of:
1. numbering documents
2. processing events on a document when the document is saved

Slawek


Add Your Comments



Email addresses provided are not made available on this site.





You can use UUB Code in your posts.

[b]bold[/b]  [i]italic[/i]  [u]underline[/u]  [s]strikethrough[/s]

URL's will be automatically converted to Links


:grin: :-D :-\ :-o :angry: :cool: :-p :emb: :cry: :huh: :-x :rolleyes: :-) :laugh: :-( ;-)






Remember me    



Bruce Elgort







Contact Bruce