Email Notifications

How can I add Email Notifications to my solution?

Notifications are built into SeedCode Complete, and if you're using FileMaker Server, you'll find this really easy. We have some example scripts in there that do things like email staff about appointments coming up in the next x hours. These scripts can be scheduled to run on FileMaker Server every x minutes and work like a charm.

First, find the "Email Notifications" folder of scripts and edit the script "Configure Mail Server Settings" to teach the solution about your mail server. Once you think you have the settings correct, run the script "Test Server Configuration" to check it out. You may see an error if you've mistyped something. Keep refining the settings until you get a test message to go though. You'll only have to do this once as all our email notifications use the same settings.

Next, find one of the example notifications and check it out. These really have two moving parts:

1. Edit the script "Notification 1 - Find Events" to script a find for the records you want to email about. In example 1 this script finds all the events coming up in the next x hours that have not yet had a notification sent. You can run this script on its own to make sure it is finding the right records.
2. Edit the script "Send one notification -- message content is edited here --" and you'll see a number of variables you can edit to determine who gets sent the notification and what the message looks like.

That's it. Once you have these calcs the way you like them, you can create a schedule on FileMaker Server to run the notification every so often. You'll have the server run the "main" script: in this example it's "Email Notification 1 - Upcoming Events".

How do I create a Schedule in FileMaker Server?

This is very easy, but beyond the scope of our docs. You'll find step-by-step instructions here (look at page 52 or just search for "script"):

Can I run notifications if I don't have Server?

Yes, but get Server. Your data deserves it.

To run this without server you can always use a "robot" machine: a FileMaker client running a plugin that can triggers scripts every X minutes. If you're thinking about this... get Server. Seriously.

If you want to run the notifications on FileMaker client--as soon as an event is edited, for example-- this can be done, but the user will feel a little pause as the event is emailed out.

Here is how to implement this...

1. You'll use the same configuration script described above, so configure and test your SMTP connection using the "Configure..." script mentioned above.
2. You'll also use the script "Send one notification -- message content is edited here --" described in #2 above, so edit that and make sure it is using the values you want to the recipient, subject, body, etc.
3. Once those two scripts are in hand, you'll call the "Send one notification -- message content is edited here --" script when you're ready to send the notification. Fortunately we're already looking to see if an event has been modified, so you can tie into that to send your notifications.
3.1 Find the script "Close Window & Refresh Calendar" (this is the script we run when you click the "continue" button at the bottom of the Event Details mini window. Edit this script and find the comment "Query our modification tracker". In the next space between script steps add an If / End If pair of steps. The calc for the If() should read:
$sc_UnModified ≠ 1
After that if statement, call your "Send one notification -- message content is edited here --" script. That's it.
4. Caveats. Since users can edit events outside this Event Detail mini window, or even just close that window without running our script, this isn't as reliable as running the script from the server. On the server we search for matching events, no matter how they were edited.

Going Further

If you want to send notifications about projects, you'll find a couple scripts already in place to help you (providing you're "on" the project's record)...

"Gather linked contacts emails for Project" returns a carriage return delimited list of the email addresses for all the contacts linked to the project.
"Gather staff emails for Project" does the same for the staff associated with the project.
Here is a great example of sending notifications when a project milestone is moved. (We're editing the event in iCal using Zulu to publish milestones from SeedCode Complete to iCal.)
You'll also find a fully abstracted script for sending mail through your SMTP server: "Send email via SMTP server { ToAddress , CCAddress , BCCAddress , Subject , Body , AttachmentPath }" By "fully abstracted" we mean that you can call this script directly, supplying the To Address, Subject, etc. just in the script parameters, instead of creating one instance of "Send one notification..." for each notification you wish to send.

Other Built-In Notifications

Project Status

The script "Project Status Changed" can be configured to send an email each time the project status changes. This is currently built into the script but turned off. Find the comment "Send email?" and follow the instructions in the If() statement that follows to turn this on. It currently uses the script "Gather staff emails for Project" to email project staff, but you can have it email projects contacts as well: see "Going Further" above for more info.

Changes to Events

We've also added a notification routine to the "continue" button at the bottom of the Event Details layout. This is the layout you arrive at when you create or edit an event in the calendar. Again, this ships turned off. Edit the script "Close Window & Refresh Calendar" and find the comment "Notify staff that this event has been changed?": follow the instructions in the If() statement that follows to turn this on.
This uses the "Send one notification..." script mentioned above, so if you want to make radical changes to the message here, consider duplicating this script and having one you just use for modified events.
[email protected]
Follow us: