« MBS Filemaker Plugin,… | Home | MBS Filemaker Plugin,… »

Sending files from Finder to FileMaker

Since the first version of Mac OS X there exist the concept of services. So one application can offer a service and another app can use it. In most cases the user simply selects a picture, some text or a file and uses a service to pass that information to an application for processing. For example if you select an image file in Finder, you can use context menu service to make it your desktop picture.

Now coming to FileMaker. In order to provide a service with FileMaker, you have to go an edit the info.plist inside the Filemaker application. First make a copy, just to be save. Open the info.plist in a text editor (e.g. TextWrangler or BBEdit). Now copy & paste the xml below into the info.plist below the top line.
	<key>NSServices</key>
<array>
<dict>
<key>NSMenuItem</key>
<dict>
<key>default</key>
<string>Pass File to FileMaker</string>
</dict>
<key>NSUserData</key>
<string>PassFile</string>
<key>NSMessage</key>
<string>ServiceInvoked</string>
<key>NSPortName</key>
<string>FileMaker Pro Advanced</string>
<key>NSRequiredContext</key>
<dict>
<key>NSTextContent</key>
<array>
<string>FilePath</string>
</array>
</dict>
<key>NSSendTypes</key>
<array>
<string>NSStringPboardType</string>
<string>public.plain-text</string>
<string>NSURLPboardType</string>
<string>public.url</string>
<string>public.file-url</string>
</array>
</dict>
</array>

This declares a service. The menu item text "Pass File to FileMaker" can of course be modified by you. Also the "PassFile" text in the NSUserData entry can be customized. It can allow your script to know which service was executed if you have multiple services. The entries for NSMessage and NSPortName must be those values to make it working. Next two entries NSSendTypes and NSRequiredContext can be customized. Here they define that we want a file path as text or URL being passed.

After you defined, the service, you can logout your Mac and/or restart. On next login, the system will recognize services and add it to the list of services in keyboard preferences. And here you should enable your new FileMaker service:



Now in FileMaker in your solution you can use ServiceProvider.Install command from MBS Plugin to register a service provider. Please do that in a script run at startup. You specify the file name of the database where the script resides and also the name of the script to call when a service request is received:

Set Variable [$r; Value:MBS("ServiceProvider.Install"; Get(FileName); "ServiceCall")]

Now in the ServiceCall script we ask the plugin for the file path and import the file into a container field:

Set Field [ServiceProvider::Paths; MBS("ServiceProvider.Value"; "Paths")]
Set Variable [$Path; Value:MBS("Path.NativePathToFileMakerPath"; ServiceProvider::Paths)]
Insert File [Never compress; ServiceProvider::File; "$Path"]

In the solution this looks like this. First we select file in Finder and choose the menu command to pass to FileMaker:



and in database we see file is imported:



Finally you can send files from Finder directly to FileMaker via contextual menu!
If you have questions, please do not hesitate to contact us. Claris FileMaker Plugin
18 10 14 - 10:27