Monday, November 30, 2009

FileMaker Flot Chart (offline charts without plugins)


When it comes to FileMaker charting, developers usually start thinking about plugins, or online web viewer (for example: Google Chart API) solutions.

In the following example I show you how you can create an offline chart in FileMaker which looks great.


I came across Flot when I was looking for javascript graph solutions, and I really liked it.
Though I will use this. You can download the source of it, which has great example files as well.

The FileMaker integration is quite simple. We'll need a field, which holds the Javascript files. (I copied the jquery.flot.min.js, jquery.min.js and the excanvas.min.js script after each other into a field (in the example file attached it's called chartsource.

Then using this, and the field data, I created a web viewer which will display those fields to me.

The example file only shows the basics of creating an offline graph, it's up to you to look at Flot documentation and create different kind of graphs.

The demo file can be downloaded from here .

Please also visit our site, http://crm.fm which has our main FileMaker product, and support us by buying it. Thanks!

The material on this document is offered as is. There is no representation or warranty, expressed or implied, nor does any other contributor to this post. Consequential and incidental damages are expressly excluded. FileMaker Pro is the registered trademark of FileMaker Inc.

Thursday, November 26, 2009

FileMaker Multiple word(part) portal filter


This technique might be known by some, but I'm pretty sure that it isn't know by many.
What we want to create is a multiple word (or wordpart) portal filter.


Many single word FileMaker portal filter demonstrations can be found on the net, but currently I needed one that can filter by multiple words.

Here's how I did it.

First we need a searchfield on the layout. I called this SearchField_Display.
Then we need a custom function that can create the variations of our fields.

I chose AllTextCombination by Peter Gort (it can be seen here, at Brian Dunning's custom function library).

With this function we create an AllVariation field based on our fields:

AllTextCombinations ( FirstName ) &"¶" & AllTextCombinations ( LastName ) & "¶" & AllTextC

ombinations ( City ) & "¶_ALL_"


The "¶_ALL_" at the end will be important later. That's used to show all the records is the searchfield is empty.


If we have this, we need three additional fields, which will help us to create a 3 word search ability. (note: if you want four words, then you'll need four, but I think 3 must be enough).


I call them SearchField1, SearchField2 and SearchField3, and they are unstored text calculations:


SearchField1:

Let ( s = Substitute ( SearchField_Display ; "-" ; " " ) ;If ( IsEmpty(s) or IsEmpty(MiddleWords(s;1;1)) ;"_ALL_";MiddleWords(s;1;1) ))


SearchField2:

Let ( s = Substitute ( SearchField_Display ; "-" ; " " ) ;If ( IsEmpty(s) or IsEmpty(MiddleWords(s;2;1)) ;"_ALL_";MiddleWords(s;2;1) ))


SearchField3:

Let ( s = Substitute ( SearchField_Display ; "-" ; " " ) ;If ( IsEmpty(s) or IsEmpty(MiddleWords(s;3;1)) ;"_ALL_";MiddleWords(s;3;1) ))


As you may notice the only difference is the word which we get from them.

I also used a Substitute ("-" to a Space char) as my data contained many "-" chars, and I wanted them as different words).


By these we can create a relation to AllVariation:



As you can see we'll have 3 criterias. (If you want 4 word you'll need 4).


After this, if we use the portal filter we'll be able to search for things like: "we la c", or "an li v" or "Bil bar abi" so basically any part of our fields.

I attached a demo file which you can download from here . (right click- save as).


Note1:The demo uses Brian Dunning's sample data database which I downloaded from here.
Note2: I used many fields in the AllVariation field which makes the index huge. You shouldn't need to do that!

Please also visit our site, http://crm.fm which has our main FileMaker product, and support us by buying it. Thanks!

The material on this document is offered as is. There is no representation or warranty, expressed or implied, nor does any other contributor to this post. Consequential and incidental damages are expressly excluded. FileMaker Pro is the registered trademark of FileMaker Inc.






FileMaker Snake game - a FM 10 Demonstration



When I first started looking at FM10's new functions (Trigger, timer, etc), I wanted to create a demo, in which I can implement almost all of these new features.

I was currently also looking at my old floppy disks, and found my snake game I wrote in Turbo Pascal when I was a small kid, and thought why not recreate it in FileMaker?

It could demonstrate layout triggers (OnLayoutKeyStroke), Timers (speed of the game)
.

Heres is what I came up with:



The main layout is a repeating field container (300 repetitions actually), arranged.
The repeating field uses a global variable and conditional formatting to show the snake and the treasure (which is set by a custom function based on it's current repetition number).
Two colors are used, Green and White:


The Snake and Treasure positions are stored in global variables as a list (eg.: 10,12 11,12, etc), and are processed by the script.

The script names of the demo file shows what they do exactly, you could easily figure them out.

The layout has a script trigger, which is to check for keyboard input, so we can move the snake.

This is a FM10 demo, which you can download from here . (right click- save as)

Note1: I did't spend too much time on optimizing this, making it prettier, etc, it's up to you. This is just a demo file, to demonstrate some of FileMaker 10's new features.

Note2: Please also visit our site, http://crm.fm which has our main FileMaker product, and support us by buying it. Thanks!

The material on this document is offered as is. There is no representation or warranty, expressed or implied, nor does any other contributor to this post. Consequential and incidental damages are expressly excluded. FileMaker Pro is the registered trademark of FileMaker Inc.

Tuesday, November 24, 2009

Filemaker MineSweeper clone


Though about creating a board game in FileMaker to demonstrate the capabilities of FileMaker Pro.
Started it, finished in about 2 hours.


So here it is, actually it's pretty straight forward and fully unlocked so you can check it.

The main fields of the database are the Display, and the Game Repeating field.
The Display shows the board, while the Game contains the yet unrevealed fields, mines.

The Init method initializes the board, sets the random mines, counts the neighbor cells (how many one mine has), etc.
The ClickHandler method takes care of the clicks, by using hidden clickable layout elements behind the repeating fields.
(Actually these clickable elements weren't created by me one by one, setting up different script paramters 300 times, instead I created a script to generate the appropriate XML for me, and then pasted it on the layout using
Clip Manager 3 by MyFmButler. (Maybe I will show this technique in a separate article later if you're interested).

The rest of the methods are a bit harder to understand, but if you check them I'm pretty sure you will see how they're working.

This is a FM8+ demo, which you can download from here . (right click- save as)

Note1: I did't spend too much time on optimizing this. I'm pretty sure scripts could be more optimized, etc. This is just a demo file, to see how much you can do with Filemaker

Note2: Please also visit our site, http://crm.fm which has our main FileMaker product, and support us by buying it. Thanks!

The material on this document is offered as is. There is no representation or warranty, expressed or implied, nor does any other contributor to this post. Consequential and incidental damages are expressly excluded. FileMaker Pro is the registered trademark of FileMaker Inc.


Filemaker - Using Growl without plugins

In this article I will show you how to create a simple Growl notification in FileMaker without additional plugins.

I have a FileMaker ToDo list, which can be filled by some people.
I wanted some kind of notification of new tasks they fill in it, without having to look at it all the time checking for new entries.

I already had Growl installed, so I thought why not use it as a notification? It has a sticky option which allows notifications to stay on the screen until I click on them. That was exactly what I needed.

That is where the following sample came from.

I didn't want to look for plugins (I am pretty sure there must be one for this), as I like to do things without plugins.
I started looking around for AppleScript samples how to use Growl, and found some on the Growl website. I modified those to run from FileMaker.

The Growl notification is a simple calculated Perform AppleScript command:

----

"tell application \"System Events\"¶

set isRunning to count of (every process whose name is \"GrowlHelperApp\") > 0¶

end tell¶

if isRunning then¶

tell application \"GrowlHelperApp\"¶


register as application \"GrowlSampleApp\" all notifications {"& Quote ("TestNotify") & "} default notifications {"& Quote ("TestNotify") & "} icon of application \"FileMaker Pro" & Case ( PatternCount ( Get ( ApplicationVersion ) ; "Advanced" ) ; " Advanced\"" ; "\"" ) & "¶


notify with name "& Quote ("TestNotify") & " title " & Quote (GrowlSample::Title) & " description " & Quote(GrowlSample::GrowlText) & " application name \"GrowlSampleApp\""& " sticky "& Quote (GrowlSample::Sticky) &"¶


end tell¶

end if¶"


----


The first part checks if Growl is up and running. The second part registers the application, and notifies with the set parameters.

The icon it shows is the Icon of FileMaker, but it can be changed to anything you wish.


We also have to check for Get(LastError) -609 to be sure.


I attached the sample file which you can download from here. (right click- save as!)



UPDATE: A commenter (doug says:) Here is a custom function that does a similar thing:http://www.briandunning.com/cf/1064


Based on ideas and code from Michael Gaslowitz http://www.gaslowitz.net/filemaker/blog/2008/07/video-growl-integration/


Thanks for that!


Note by Adam: However that custom function needs to be modified a little bit, as it doesn't checks for the GrowlHelper app running, be sure to change that!






Please also visit our site, http://crm.fm which has our main FileMaker product. Thanks!

The material on this document is offered as is. There is no representation or warranty, expressed or implied, nor does any other contributor to this post. Consequential and incidental damages are expressly excluded. FileMaker Pro is the registered trademark of FileMaker Inc.




Sunday, November 22, 2009

Filemaker - Applescript Printer list / faxing a file

In the following artice I will show you two methods that I have created in my solutions.

If you want a list of your installed printers in FileMaker you can use a simple applescript.

I show you two methods. Each of them requires a PrinterList_Global field in your database and on the layout where you execute the script. The script is a simple Perform Applescript command.

The first method uses the print setup utility to get the printer list. You need to have a PrinterList_Global field in your database and on the layout where you execute the script:
----
tell application "Printer Setup Utility"

set allprinters to every printer

set printernames to name of every printer

end tell


set backvalue to ""


repeat with printername in printernames

set backvalue to backvalue & printername & (ASCII Character(13))

end repeat


set cell "PrinterList_Global" of current record to backvalue

---


This can be used to set the default printer on OSX.


2)


The second option uses the lpstat OSX command to get the printer names. This will give you a different list. But the printer names this one gives can be used for the "lp" OSX command. This will be important later when we get to fax sending.


---

set oldDelims to AppleScript's text item delimiters

set PrinterStatusList to {}

try

set cmd to "lpstat -p | grep ^printer"

set PrinterStatus to do shell script cmd as text

set AppleScript's text item delimiters to {" "}

repeat with i from 1 to count of paragraphs of PrinterStatus

set s to paragraph i of PrinterStatus

set p to text item 2 of s as list

copy p to end of PrinterStatusList

end repeat

on error

set PrinterStatus to ""

end try

set AppleScript's text item delimiters to oldDelims


set backvalue to ""


repeat with printername in PrinterStatusList

set backvalue to backvalue & printername & (ASCII Character(13))

end repeat


set cell "PrinterList_Global" of current record to backvalue


--


Okay, now you have the printer list. You can easily create a value list based on this, and let the user choose from it.


What about faxing??


This is where the lp command comes in.

With lp you can send a file (pdf), to a number.


The syntax is the following:


lp -d PrinterNameHere -o phone=PhoneNumberHere filepathandnameHere


You can call this from FileMaker using a do shell script AppleScript Command.


I attached a sample file for printer listing, the faxing is up to you, but based on this, you can easily create it.


You can download the demo file here. (right click - save as).


Be sure to check out: http://crm.fm as well :) Thanx!

The material on this document is offered as is. There is no representation or warranty, expressed or implied, nor does any other contributor to this post. Consequential and incidental damages are expressly excluded. FileMaker Pro is the registered trademark of FileMaker Inc.





Saturday, November 21, 2009

Highlight Active Portal record with Conditional Formatting

Here's a demonstration file I created for highlighting active portal record using conditional formatting.


The attached example is a picture browser with a simple navigation system, and a preview portal. (I know it's ugly but it's just a technique demonstration ;)

I could have used a container field to highlight the active portal element, but conditional formatting makes our life simpler :)

I created a an empty (well, actually it has a space char in it) text element, resized it to th
e portal element size, then applied the following conditional formatting to it:


(Set Formulat to: If the related ID equals to the Current id, then apply a Fill color)


After this I put this text under the portal picture field, and send it backward.

I attached the demo file which you can download to analyze the technique.

You can download it here. (right click, save as)

Be sure to check out: http://crm.fm as well :)

The material on this document is offered as is. There is no representation or warranty, expressed or implied, nor does any other contributor to this post. Consequential and incidental damages are expressly excluded. FileMaker Pro is the registered trademark of FileMaker Inc.