1. FileMaker Server is very well documented. All the FileMaker Server documentation can be found in “FileMaker Server/Documentation/” on any machine the product is installed on. The Custom Web Publishing API is covered in FMS9_CWP_XSLT_en.pdf, a document titled FileMaker® Server 9 Custom Web Publishing with XML and XSLT. This is a 2MB, 122-page pdf covering much more than you need to know to use FlexFM. For reference purposes when working with FlexFM, see “Appendix A” (pages 87-104).
2. Conveniently, page 87 of FileMaker® Server 9 Custom Web Publishing with XML and XSLT, shown below, contains a complete index of the commands available, along with page references. There is a small handful of commands available only for XSLT included in the list, but those are clearly marked. Don’t concern yourself with those commands marked as “XSLT only”.

3. As mentioned in the previous lesson, you will want to use FireFox. Unlike some browsers, FireFox does a nice job of displaying raw XML. Before we begin requesting data with Flex, we’ll review some basic command syntax and test the results in FireFox.
4. In the previous lesson, I suggested that you test your server’s XML response with the following url in FireFox:
http://localhost/fmi/xml/fmresultset.xml?-db= FMServer_Sample&-lay=English_List_View&-findany
If you aren’t getting results like this, go back a few steps or get some help to figure out why your server is not returning results.

5. The command string above is about as simple as you can get. Let’s break that down into four basic sections:
The first section is kind of obvious. Depending on the deployment, this section might also specify credentials and/or a non-standard port. This part is handled by FlexFM. Learn enough about it so that you can debug effectively:
http://localhost/fmi/xml/fmresultset.xml?-db= FMServer_Sample&-lay=English_List_View&-findany
The second section simply directs the request to the right grammar on FileMaker Server’s Web Publishing Engine. This section is also handled by FlexFM:
http://localhost/fmi/xml/fmresultset.xml?-db= FMServer_Sample&-lay=English_List_View&-findany
The third section consists of two special arguments—required for almost every command. Note how the names of the command arguments are preceded with a dash character. The API does this to avoid conflicts with data-field names, as dash is an illegal leading character in FileMaker field names. Note that rather than specifying a base table, FileMaker expects a layout to be specified. This is a boon for performance enhancement, as you can limit the number of fields returned by specifying a layout that contains only the fields required for your query. This also allows you to return related records by putting portals on your FileMaker Web layouts. In the command string that we are using as an example, we specify “English_List_View“, but you might also choose the more verbose results returned by “English_Form_View“. FlexFM has methods that handle the syntax for these two arguments:
http://localhost/fmi/xml/fmresultset.xml?-db= FMServer_Sample&-lay=English_List_View&-findany
The fourth and last section is the one which actually handles commands and queries. In the simple example we have been looking at, we specified a special query command, -findany, which returns a random single record.
http://localhost/fmi/xml/fmresultset.xml?-db= FMServer_Sample&-lay=English_List_View&-findany
6. FlexFM has methods that take care of the first three sections of url strings. This leaves the last section for you to construct as your application requires. With FlexFM and the FileMaker “query commands and parameters” documentation for reference, you will be able to construct command strings to do anything FileMaker Server is capable of by using some simple text parsing in ActionScript. Fields are specified with the name in standard name/value pair url syntax, and field contents are specified as the value. All command strings must be url encoded. Here are some examples that will work with the FMServer_Sample file that comes installed with FileMaker Server.
This command will return the first three records of the entire table:
This will create a new record for the 500 copies of the Soliant book I just photographed:
Title=Soliant&Cover%20Photo%20Credit=Jeremiah%20 Small&Status=Test&Quantity%20in%20Stock=500&-new
This will lookup the record we just created:
Note that when you run each of the above three command strings in place of -findany, the browser returns the record set that you just operated on, even if the command was not explicitly a query. Note also that every record returned has two properties called mod-id and record-id. The record-id property is a unique integer for every record in a given table. The mod-id property is an integer which starts at 0 when a record is created, and increases by one each time a change to that record is committed. The mod-id property is important to ensure that the record you requested has not changed in the interim before you submit any change to it. So let’s say you ran the above commands, creating a new record, and the result comes back with mod-id=”0″ record-id=”13″. You can run the following command to update the quantity:
This command will delete our hypothetical record-id=”13″.
Armed with this basic information, you are ready to start rolling your own application with FlexFM.
7. One last thing before you get started. When something doesn’t go as expected, FileMaker will do its best to tell you what’s happening. All of the FileMaker Pro error codes are listed in the documentation that ships with the product and are available online.
Next: Get FlexBuilder 2 or Create a Flex app with FlexFM










|
Posted by jsmall on July 15, 2007 at 11:37 pm

First and foremost, thank you!!! Ever since I discovered you could use FileMaker and Flash/ActionScript technology I was excited about the possibilities, then reality hit. The learning curve is daunting (for a beginner).
The FlexFM is a great tool that will greatly reduce development time, I can’t wait to learn more. I will not be able to attend the Dev Conference in July, I would have to love to attend Mr. Love sessions on Flex. I would be willing to pay for the reference materials? Anyway, keep up the great job and thanks again.
Best!
Thanks for the kind words. I realize that we only trickle improvements out, but keep your eye out this month for some pretty exciting enhancements, including a PHP class built for Flex called FMProxy, which allows you a great deal more power when using form authentication, as well as allowing you to mask your FileMaker Server from the public Internet. I’ll include sample files demonstrating how to do this, which has been previously requested, and will make your FlexFM development process much easier.
Looking forward to it! Also, I know there has been some discussion about accessing FM data when the swf file is on a web server…if possible, could you please point me in the right direction. Thanks again!
Yes, these two issues are essentially one and the same (except when you are allowing anonymous access to your FM data, and then you can just do it as is).
I just want to say thank you, I noticed that apparently nobody is using FlexFM…
It is really only apparent, I’m using it and waiting for the new PHP class.
I’m a Filemaker in house developer, not a professional.
Ah yes, I did promise to publish that. This week, I promise! Thanks for asking.
Perhaps this thread is abandoned (hopefully not FlexFM completely). The issue I’m having is retrieving the ID property after FM returns the data to Flex. For example, I’m querying the database for a single record (using MY Primary key). I then populate a form with the existing values which are returned. I now want to save the edits the user makes. I need to include the record-id in the query (don’t I?) and I can’t seem to get access to the record-id property. The hyphen throws flex off (I’ll get something like “Can’t find a property called ‘record’ of the object” or I get “Implicit coercion of a value of type String to an unrelated type Number.”
I’m trying to access it like this: “detailRequest.lastResult.records[0].@record-id” but I’ve tried it without the ‘@’ and several other tweaks to no avail.