Scripted Exports

 <  Day Day Up  >  

That covers just about all the possibilities for manually exporting data from FileMaker. It often happens that the same kind of export needs to be done repeatedly. Examples might be the sending of sales reports to a home office, or perhaps generating a telephone contact list. In cases where an export operation needs to be done on a regular basis, it makes sense to use a script to automate the process. There are additional issues to consider when setting up a scripted export. Take another look at the database shown in Figure 20.1. The same export can be automated so that users can run it by just clicking a button. That makes it possible for people who have no expertise with FileMaker or even your data requirements to successfully export a properly formatted file.

To create such a script, select S cripts, S criptMaker to bring up the Define Scripts dialog. Create a new script called Export Tab File and add an Export Records script step to it, as shown in Figure 20.10.

Figure 20.10. The Export Records script step can be set to run with more or less user interaction.
graphics/20fig10.gif

Check Specify Output File to bring up the Specify Output File dialog shown in Figure 20.11.

Figure 20.11. The Output File Path List can be used to allow a single script to adapt to multiple user export environments.

graphics/20fig11.gif


The Specify Output File dialog controls the file format that gets exported, and it controls the potential locations to which it can be exported by means of the Output File Path List. The Output File Path List is a powerful tool (available only for scripted exports, not manual exports) that allows a single script to work properly in a variety of user environments. A user might log on to a database from a home computer, or at the office, or from a Terminal Server session, and in each case might have different drive configurations, even while using the same database.

As a developer, you can set up an output file path for every possibility by clicking the Add File button. When the script is run, FileMaker works through the list to see whether any of the file paths are valid. The first valid path that it finds is the one it will use to export the file. You can rearrange the order of the file paths to force FileMaker to check one location before it checks another. If none of the paths are valid, you get the error dialog shown in Figure 20.12.

Figure 20.12. If none of the scripted Output File Paths are valid, FileMaker displays this error message.

graphics/20fig12.gif


You cannot suppress this dialog by using the Set Error Capture script step. It always displays if none of the file paths are valid. After the Output File Paths and the File Type have been specified, click OK to exit the Specify Output File dialog and return to the Edit Script dialog.

Check Specify Export Order to bring up the Specify Field Order for Export dialog, as shown in Figure 20.13.

Figure 20.13. When you script an export, you use the same Specify Field Order for Export dialog that you use when you perform the export manually.
graphics/20fig13.gif

After you've set the Field Export Order, Group By, and Layout Formatting options, click OK to exit the Specify Field Order for Export dialog. Click OK again to exit the Edit Script dialog, and your script is ready for use. Be sure to test it from the various user environments so you can be sure it will function properly when different directories are available.

The Export Field Contents script step works in an identical fashion. It has the same option to set multiple output file paths. The only difference is that the Export Field Contents script step applies to only a single field on a single record. It doesn't export field contents for every record in a found set. If you need that functionality, you can put the Export Field Contents script step inside a looping script that moves from record to record.

For more information on constructing looping scripts, see "Common Scripting Techniques," p. 249 .


 <  Day Day Up  >  


QUE CORPORATION - Using Filemaker pro X
QUE CORPORATION - Using Filemaker pro X
ISBN: N/A
EAN: N/A
Year: 2003
Pages: 494

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net