Filemaker applescript examples download mac
For example, if we were to delete the first record in my database, then record 2 would become record 1, and, therefore, it would have a new index number. These ID numbers are internal to FileMaker, and are assigned to records when they are created. Once an ID has been assigned to a record, it will not change. Therefore, a more accurate way of referring to a record would be to use its ID. To determine the ID of a given record, you may access the ID property of that record.
For example, the following code will retrieve the ID number of the second record in the specified database.
FileMaker Pro Advanced 17 review: Plenty of great reasons to upgrade to this latest version
Once you have the ID number for a record, then you may refer to that record by using its ID. For example, the following code will find and show a specified record, using its ID, rather than its index number. In some cases, rather than accessing an existing record, you may need to create a new record in a database. This is done by using the create command, and specifying in which database you would like to create the record.
The following example code demonstrates the proper usage of this command. As you can see from the code above, the result of the create command, is a reference to the newly created record. This information could be placed into a variable for later usage in your script. There may also be times when you need to delete records in your database. This can be done by using the delete command. The following code demonstrates how to delete a specific record of a specified database. As another example of the delete command, the following code will delete every record in a found subset of records, within the specified database.
Notice that, since we want to interact with a found subset of records, the document class is referenced, rather than the database class. When manually creating a FileMaker Pro database, one of the first things you will do is add fields for the different types of data that your database will hold. FileMaker Pro's AppleScript dictionary defines two classes for use when interacting with fields. First, a field class pertains to the actual fields within the context of a database itself, and not within the context of a specific record within that database.
This can be illustrated through the following two code examples. This first example will count the fields within our sample database. Since there are 8 fields in this database, the result of this example code is a value of 8. This next example will attempt to count the fields within a specific record of our sample database. Since fields are not contained by records, this code results in a value of 0. The second class that is defined for interaction with fields in a database, is the cell class. In FileMaker Pro, databases contain fields and records. Records contain cells, which contain data and correspond to fields.
The following example code shows that counting the number of cells within a specified record in our sample database returns a value of 8.
- .
- BEFORE YOU BEGIN!
- arturia arp 2600 download mac;
- converting mini dv tapes to dvd on mac!
- SMS Mac – AppleScript.
- Automator: Examples!
- performance mac mini vs imac 2012.
Now that we have discussed different ways to refer to fields, let's discuss how to retrieve data from fields. To retrieve the contents of a field within the scope of a single record, refer to a specific cell class contained within that record. For example, the following code will retrieve the value of the Name field for the first record in our database.
As you can see by the code above, it is not actually necessary to reference a parameter of a cell in order to retrieve the cell's value. Simply referring to the cell itself will result in the value of that cell. Other methods of requesting a cell's value include, using the get data command, as well as accessing the cellValue property of the cell class. To retrieve a field value from multiple records at once, you may refer to the field class within the scope of a database itself, rather than a record. For example, the following code will return the value of the Name field for every record in the specified database.
Again, in this situation, referring to the document class rather than the database class would allow us to access records within the found subset of records, rather than within the entire database. The following example code will return the value of the Name field for every record in the found set of the specified database. Fields also have properties, which may be of use to you as you script FileMaker Pro. For calculation fields, a formula property may be referenced to retrieve the calculation text for the field. For fields that have been assigned a value list, such as the Powers field in our sample database, the contents of that value list may be retrieved by referencing the choices property of the field.
The following code demonstrates how to retrieve a value list for the Powers field in our sample database. Now, let's discuss how to populate fields with data. The following example code demonstrates how to set the values of multiple fields within in a given record. AppleScript can also be used to populate container fields with images and other types of data using this same technique.
To populate a container field with a file, set the value of the cell to the path of the desired file. For example, the following example code will prompt the user to select a photo of Wonder Woman. It will then create a record for Wonder Woman, populate some text fields, and insert the chosen photo into the Photo container field. Now that we have discussed basic record and field interaction, let's return to records again.
Two primary tasks that you may want to automate in FileMaker Pro using AppleScript are, performing finds and sorting records. There are two ways to find records in a database.
AppleScript.Run
The first is to make use of the show command. The following example code demonstrates how to use this command to find and display all of the records within the specified database.
To find and display records that match certain field values, you can still use the show command. However, you must specify the criteria for what you would like to find. This is done using the whose clause, and specifying the field you want to search, along with the value you want to locate within that field. For example, the following code will find and display every record in our sample database with a value of Superman in the Name field.
A similar code variation can be used to search for records using multiple fields and values. The code below demonstrates this technique. This code will search our sample database for any record with a value of Superman in the Name field and a value of Clark Kent in the Secret Identity field. Another method of finding records is to make use of FileMaker Pro's find requests. When you perform a find in FileMaker manually, by selecting Find Mode from the View menu, a new find request is created.
You can then enter search values for any desired fields within the request. Additional find requests may also be added, if desired, and even omissions may be specified. This can allow you, for example, to perform a find for every record where field x contains a specific value and field y does not contain a specific value. See figure 5 for an example of a find request in a FileMaker Pro database. Figure 5. Find requests may also be created using AppleScript, and are represented by the request class.
AppleScripts and Field Contents
To create a new find request, use the create command. Once a request has been created, much in the same way that you set field values for records, you may specify field values for the fields within find request. Once all field search values have been specified, you may then issue the find command to perform a find using any current find requests.
The following code will perform a find by creating a find request. Prior to creating the request, any existing requests will be deleted, ensuring that no previous requests are included in the search.
FileMaker 17 for novices
Once this find request has been created, search criteria are specified by setting values for certain fields within the request. Next, the find command is issued. Like performing a find manually, AppleScript can create multiple requests prior to issuing a find command. The following example code will delete any existing find requests, and create a new request for any records with a value of Super Strength specified in the Powers field. Next, a second request will be created that will omit any records with a value of Flight in the Powers field. The find command will then be issued.
So, in other words, this code will perform a find for any records in the database that have a value of Super Strength, but not a value of Flight specified in the Powers field. Using the techniques mentioned above, AppleScript can be used to perform virtually any type of find in FileMaker Pro, regardless of how complex.
Sorting records is another important task when working with databases in FileMaker Pro. At times, you may want to sort the records within your database, based on data within certain fields. The next step is to generate the timestamped filename that will be used when creating the. The actual AppleScripts were cobbled together from various examples that I found on the Internet as well as making use of the FileMaker Pro Apple Events reference database.
You can download a copy of my backup tool here: This database was created and tested under Mac OS X Here are some references that you might also find useful if you wish to modify this tool yourself or learn more about AppleScript and FileMaker:.
SMS Mac - AppleScript
Introduction to AppleScript Language Guide. AppleScript Error Codes. Keeping good backups — a simple snapshot tool Goya. A Simple Backup Script filemakerhacks. Blog - Latest News. It has 4 fields that I use to store the locations to: To do this I perform a very simple AppleScript:.