Growl Integration with FileMaker


FileMaker dialog boxes can be informative, but sometimes they are just annoying. You have to click them to get them to go away. Lots of times, you just want to give a little bit of feedback to the user, so they they get a clue as to what your scripts are doing, without requiring them to do anything, but a dialog box is just overkill.

That is where Growl comes in. Growl is a FREE system-wide notification system for Mac OS X, that, as their website states “…lets Mac OS X applications un-intrusively tell you when things happen.” I like to think of Growl as a ‘dissolving’ dialog box. It shows up, hangs around for a couple of seconds and then gracefully fades away. Best of all, no clicking is required. Even when you set the ‘sticky-ness’ option to on, the Growl dialog box will stay on screen until clicked, but will not interupt the workflow of the user.

A while back, I was watching a video done by another developer named Michael Gaslowitz about integrating Growl into FileMaker. The video is still available on his website www.gaslowitz.net and worth watching. Michael did all the hard work on this, but his version was more complex than I needed, so I proceeded to create a stripped down Custom Function to send out an Applescript call to Growl. His ideas are great, but did more than what I needed. My goal was a simple function that I could feed messages into. His system has two other custom functions to feed in the version of FileMaker being used (Pro or Advanced) and adds in the ability to do custom icons loaded from FileMaker into a Temp directory. He also has a script parameter feeding system to allow you to enter all the needed parameters when assigning a script to a button. This also used more custom functions. I cut out all that good stuff just to get it working simply. It is definitely worth a look at his video to see how this could be expanded, and because he has a script that checks for the presence of Growl.

My simplified version of his work is a Custom Function called ‘FMGrowl’. If you just want to grab the Custom Function, click this link: www.briandunning.com

Sample of a ‘dissolving’ Growl message

media_1278961156339.png

Growl makes nice transparent floating window dialog boxes. They don’t stop the user from doing anything, preferences can be set to have them display in different areas of the screen and they can be set to hang around, or dissolve after a couple of seconds.

1) Add the Custom Function FMGrowl to your FileMaker solution

wpid435-media_1278919616900.png

In FileMaker, add the Custom Function FMGrowl to your Custom Functions area, under the File Menu, Manage item: Custom Functions item.

FMGrowl Custom Function

wpid436-media_1278919631449.png

If you are using FileMaker 11, you can paste this Custom Function in from the demo solution, or click the ‘New’ button and copy and paste the bits in from the description on the www.briandunning.com website.

Adding the Custom Function manually

wpid440-media_1278922775325.png

FileMaker 11 allows you to copy and paste Custom Functions from other FileMaker files, so you can just copy and paste from the demo file. If you are working with an earlier version of FileMaker (back to FM 7, should work, as all it is doing is calling an Applescript)

To add a Custom Function by hand, you will need to enter the following

1) Custom Function Name
2) Enter the variable names – then click the
3) Plus button to create the variable.
4) Paste the main body text from the Custom Function www.briandunning.com website into the main Custom Function area.

You can safely skip this next information unless you are interested in the workings of Custom Functions.

/* FMGrowl (title, description, sticky)

Parameters: Are all text fields
message – the name of the floating dialog box.
title – the title of the box.
description – the text in the main message of the box.
sticky – text field that takes the values: {yes, no}. This determines if the Growl message hangs around on the screen or not.

Applescript steps involved:

–Register the script with Growl. I am using the default FileMaker Application icon. There is a Case switch in there to deal with FileMaker Pro or Advanced, as Applescript is specific about the program name.
–send a notification to Growl

*/

“tell application \”GrowlHelperApp\”¶

    register as application \”FMGrowl\” all notifications {“& Quote (message) & “} default notifications {“& Quote (message) & “} icon of application \”FileMaker Pro” & Case ( PatternCount ( Get ( ApplicationVersion ) ; “Advanced” ) ; ” Advanced\”” ; “\”” ) & “¶

    notify with name “& Quote (message) & ” title ” & Quote (title) & ” description ” & Quote(description) & ” application name \”FMGrowl\””& ” sticky “& Quote (sticky) &”¶

end tell”

Test for Growl on Startup

wpid437-media_1278919666940.png

Now that the Custom Function is installed, the first thing you probably want to do, is run a test for Growl’s presence on startup. Here are the details of the start up script. You may want to add this script to your ‘On Open’ script.

On Open script

wpid442-media_1278922936655.png

The On Open script is often used to direct the user to a specific layout when the database opens. It is a good place to add scripts that you want to run when the database first opens.

File Options

wpid443-media_1278922951223.png

To set the On Open script to run when launching a FileMaker Database, click under the File Menu on the ‘File Options’ item.

Under the Open/Close tab, in the area for ‘When opening this file’, check the ‘Perform Script’ option

wpid444-media_1278922963060.png

When the dialog box opens, select the script ‘On Open’. Then click OK. Now, whenever you launch the file, this script will run.

What the ‘Test for Growl on Startup’ Script actually does.

wpid441-media_1278922879116.png

If it is running, Growl will display a brief message announcing its presence. If it is not, an error number is returned.

If you get the error message -609 back, it indicates that Growl is not present. In my script, this prompts a dialog box recommending the user install Growl for optimal performance. You may want to combine this with some information about where to download Growl, which remains a free application.

FMGrowl Demo file

media_1278961787970.png

I have created a demo file to show how this work. Enter some text in the variables and click the ‘Growl’ button to test.

1) the title
2) the message
3) select ‘sticky’ as either yes or no. Yes means the message will hang around until the user clicks it away. No means it fades after a few seconds.
4) description is optional, and there to help you remember why you added the growl in the first place.

5) Click ‘Growl’ to test.

Sample Growl script

wpid438-media_1278919690249.png

The above is a fairly standard conditional script, that looks for a script parameter and then runs different versions of the script, depending on what the script parameter calls for.

As you can see in the script descriptions, all that is needed is that you feed in a few script parameters, specifically.

$title – the main alert
$message – more detail on the alert
$description – is optional.
$sticky (boolean) – yes or no to make the message stick around for more than a few seconds.

The format to call the Applescript is

Perform Applescript [FMGrowl($title, $description, $sticky, $message)]

Then the Applescript fires off based on the variables supplied and calls Growl, feeding it the title, description and whether or not to hang around until the user clicks away the Growl notification.

A Growl message

wpid439-media_1278919931326.png

You have probably seen Growl in action, but what you see is a message which displays for a moment or two before fading in to the background.

A Growl Message with ‘sticky’ set to Yes

media_1278962110468.png

With ‘sticky’ set to ‘yes’, the message will stay around until the user clicks it away. Unlike a standard dialog box in FileMaker, the Growl alert does not stop any actions in FileMaker. When the user hovers their mouse over the message, a close box appears in the top left of the window to dismiss the message.

Controlling Growl

media_1278962713673.png

This is not the time or place to go into the full details of Growl, but just to make you aware of all the granular control you can take on Growl. Growl has a control panel in the System Preferences of OS X, under the Apple Menu. For more details on harnessing this power, go to the documentation on Growl

Download Demo File Here

media_1278962592296.png

Advertisements

4 Responses to “Growl Integration with FileMaker”

  1. There’s also a great free plugin for doing this : http://www.banks.id.au/software/fmgrowler/ I’ve integrated it into some things that I’ve done, and it’s simple and works perfectly. The way I did it was to just test for the presence of the plugin, and if it exists then use the growl notifications. That way users can activate the growl notifications in your app just by installing the plugin.

    Cheers,
    Nick

    • homebasesoftware August 14, 2010 at 2:09 pm

      Good tip. Thanks Nick. Philosophically, I would take AppleScript over a plugin, but as with most things FileMaker, it is good there are multiple ways to do it.

Trackbacks/Pingbacks

  1. Move Selected Files into a New Folder using AppleScript and Automator | HomeBase Software - July 13, 2012

    […] Articles: Growl Integration with FileMaker Shortening URLs […]

  2. Replacing a Time Machine Backup Hard Drive | HomeBase Software - July 21, 2012

    […] Related Articles: ScreenSteps vs MacSnapper Move Selected Files into a New Folder using AppleScript and Automator Growl Integration with FileMaker […]

%d bloggers like this: