by Kirk Bowman <kirk@mightydata.com>
RATING: Intermediate
VERSION: FileMaker 5/6
PLATFORM: Macintosh & Windows
TECHNIQUE FILES: Pictures65_5.fp5, DemoFiles65_5.fp5
WEB: http://www.filemaker.com
Editor's Note: This article is continued from Issue 66, Section 4.
Data on the Road: FileMaker Mobile 2
The CompuHut sales force needs to take accurate information on the road in a compact format. Paper printouts were used in the past, but today Palm handhelds are the weapon of choice. To take FileMaker databases on the road, FMI (FileMaker Inc.) has created FileMaker Mobile. With FileMaker Mobile on a Palm, a sales person has access to the current customer list, invoice history for the customers and the latest product catalog.
FM Mobile consists of three pieces of software--the Palm application, the HotSync Conduit and a plug-in for FileMaker Pro. The plug-in is the interface to configure the database and fields that are copied to the Palm.
Choose Edit>Preferences>Application. Click on the Plug-ins tab. Make sure the Mobile Companion is checked. This enables the FM Mobile plug-in. Close the dialog box (Picture 3.1).
Open the database you want to sync to the Palm and choose File>Sharing. Make sure Mobile Companion is checked. This tells FM Mobile to copy this database to the Palm.
Click on the Settings button. In the next window, click on the Specify Fields button. In a dialog box similar to Sort Records, select the fields to copy to the Palm. Note only text, number, date and time fields can be copied to the Palm (Picture 3.1).
By highlighting a field and clicking on the Properites button, you can configure how the field is displayed on the Palm.
Once the fields are configured, you have to determine which records to copy to the Palm and how to handle conflicts during synchronizatgion. For the salespeople, Customers is set to "Handheld overwrites desktop" while Invoices and Products are set to "Desktop overwrites handheld" (Picture 3.3).
FM Mobile: Multi-User Work-Around
The previous steps enable a database to be copied to the Palm. However, FM Mobile has a limitation we need to address. It can only synchronize a database opened as a host. In other words, the desktop computer must be the first to open the database. This prevents synching with a database hosted on FileMaker Server.
To work around this limitation, the procedure is to copy records from a database hosted by FileMaker Server to a database opened only on the local workstation. Next, synchronize the Palm and the desktop database. Third, update the server database using the Import Update technique discussed in the previous section. The following diagram shows the flow of data.
As an example, to synchronize the Customer database, a clone of it is placed on the users local hard drive and renamed to Customers Mobile. Since both databases will be open during a HotSync, a different name is necessary to avoid confusion. The following script "ImportFromCustomers" deletes all records in Customers Mobile and then imports the records from Customers.
Show All Records
Delete All Records [No dialog]
Import Records [Restore, No dialog, "Customers.fp5 (*)"]
Since the salesperson needs to synch customers, invoices and products, the following script "InitializeForHotSync" prepares each desktop database by performing a Show All in the server database and then deleting all records in the desktop database and importing from the server database.
Perform Script [Sub-scripts, External: "Customers.fp5 (*)"]
Perform Script [Sub-scripts, "ImportFromCustomer"]
Perform Script [Sub-scripts, External: "Invoices.fp5 (*)"]
Perform Script [Sub-scripts, External: "Invoices Mobile.fp5"]
Perform Script [Sub-scripts, External: "Products.fp5 (*)"]
Perform Script [Sub-scripts, External: "Products Mobile.fp5"]
Beep
Show Message ["Mobile databases are ready for a HotSync."]
Running the initialization script is the first of the three steps to synchronize with the server. The second is to perform a HotSync by pressing the button on the Palm cradle. The third is to perform an Import Update from the desktop database to the server database. The following script handles the Import Update for Customers (See Picture 3.5) An Import Update is not necessary for Invoices or Products because salespeople cannot change theses tables on the Palm.
Show All Records
Perform Script [Sub-scripts, External: "Customers.FP5 (*)"]
Internet and Extranet: Web Companion
The final piece of CompuHut's information hub is the Web. Two features need to be added to the Web site. First, a visitor to the Web site can browse the product catalog. This is a classic example of the Internet. Second, an existing customer can login with a username and password and view his order history. This is an example of an Extranet--a system between a company and their clients and/or vendors that has protected access but uses the Web as the network between the physical locations.
The Web Companion plug-in gives FileMaker Web server functionality. To enable the Web Companion, choose Edit>Preferences>Application. Click on the Plug-ins tab and make sure the Web Companion is checked
Click the Configure button. Although the settings for the Web Companion will vary depending on the Web site, the following settings are most important for this demostration (Picture 4.1).
1. Uncheck Instant Web Publishing.
2. Select "default.html" as the home page. (The HTML files must be in the Web folder inside the FileMaker folder.)
3. Make sure the TCP/IP Port Number is 80.
4. Make sure Security is set to FileMaker Pro Access Privileges.
5. Next, choose File>Sharing and make sure Web Companion is checked under Compaion Sharing. (This step is necessary for Customers, Invoices and Products.)
CompuHut Web Site
Now that the Web Companion has been enabled and Web Companion sharing has been enabled in each database, test the CompuHut Web site. Type the IP address of the computer running the Web Companion in your Web browser and the Home Page should be displayed (Picture 4.3).
Clicking on the "Browse" link will display a list of products. Since CompuHut has so few products, it is easy to display them on a single page. For a real company, a search feature would be necessary for the product catalog.
The other option on the home page is the Customer Login. This allows a customer to view his customer history without anyone else viewing it. This is an example of an Extranet.
If the username and password are invalid, the following dialog "No Records Found: Modify your search criteria and try again" will be displayed.
If the login is successful, a list of invoices is displayed. The username "carol" and the password "cb" should display the following list (See Picture 4.4).
Bonus: Secure Login with CDML
The CompuHut Web site was built using CDML, the programming language for the Web Companion. Although a full discussion of CDML is beyond the scope of this paper, the login technique will be explained because it demonstrates a new technique discovered while building the site.
Usually logins with the Web Companion are not 100% secure. This is due to the default search behavior of FileMaker. When you perform a Find in FileMaker, it searches for all words beginning with the letters entered. This is using the default search operator Begins With. For example, if you search for "jo" in the First Name field, the find results will contain Joe, John, Jonathan and so on. To find just "jo" you need to use the Exact Match search operator which is ==.
Previously, the only way to accomplish an Exact Match search was to use JavaScript to validate the search criteria. Below is HTML that will perform an Exact Match search.
<INPUT TYPE="hidden" NAME="username" " VALUE="==">
<INPUT TYPE="text" NAME="username" SIZE="24"></TD>
<INPUT TYPE="hidden" NAME="password" VALUE="==">
<INPUT TYPE="password" NAME="password" SIZE="24>
The trick is the hidden Input tag before the text Input tag. The Value attribute is ==. Since both the hidden and text Input tags have the same Name attribute, the Web Companion concatenates the Exact Match operator with the search criteria entered. In other words, the customer may enter "carol" for the username but "==carol" is send to the Web Companion. The same thing happens for password.
Conclusion
These features are not the only tools available to expand the information hub. For example, an SQL plug-in is available to turn FileMaker into a true front-end for a back-end SQL database. For the Web, Lasso is available to develop sophisticated Web sites that are not possible with the Web Companion. Regardless of the tools used, FileMaker is a viable platform for the hub of an information system.
Happy FileMaking!
Kirk Bowman <kirk@mightydata.com> is a FileMaker Pro trainer, consultant, developer and President of Mighty Data, co-sponsors of FMPWorld and Lasso Summit. For more information, visit <http://www.mightydata.com>.