Skip to main content

Filtering: Downloading Found Sets

Can someone in the field download just their data?

Yes. GoZync lets you build a found set of records to bring down to your mobile device. These could be the records for a given user ("my contacts") or the records for that user which are flagged to be done that day ("my appointments for today"). You get to build the found set using whatever scripts you'd like – you're in FileMaker, after all – and GoZync will package up the resulting found set for the mobile user.

Filtering Videos

Todd Geist has a great video walkthrough on filtering in GoZync 5, including examples of filtering by user name and by the current location of the iPad:   "Filtering by UserName and Location".

Todd also demonstrates filtering as part of his   "Three Favorite GoZync Features".

How it works.

There is a single script in your hosted file that controls bringing data down to a mobile device. The script is named "Filter Records To Pull" and is one of the scripts you imported into your hosted file during integration. In our example file it's in the file WorxHosted.

The script begins by performing a "Show All Records" command.

If you leave it like this, all records will be considered for sync. Of those, only those that have changed since the user's last sync will be brought down.

But you can modify this script to build found sets depending on the table being synced. Each table you want to do this for would get its own branch (its own "IF" section). Here is what one such branch might look like:

We're pulling the entity "WorkOrders", performing a find that only grabs the records tagged to be checked out. Using simple FileMaker Finds like this, you can easily add sophisticated syncing behaviors to GoZync.

Tips for building found sets.

Authentication. Remember, your mobile user has  logged into your files at this point (has been asked for a user name and password) so you can use Get ( AccountName ) to determine who they are and search for only their records. You also have access to Get ( UserName ), but this is often something like "Bill's iPad" and is something users can change--pretending to be someone besides Bill, for example. Learn more about  Retrieving Account Names.

Check Out. In addition to "my" records, you may want to have mobile users download records that have been tagged in some way, such as deliveries that need to be made that day. Including this Tag in the find criteria is easy, and you can often use this tag to prevent users back at the office from editing records that a mobile user has " checked out".

Overriding Last Time Zync'ed. In the script "Filter Records To Pull" you'll see a few disabled script steps that can be used to ignore the last Zync time and bring down a found set regardless of when the user last Zynced. This is really only useful to developers who may be working with smaller sets of data that don't have an accurate modification time, or who are using  checkout. In most cases you'll leave these steps commented out.

Run the script in isolation. Navigate to the TO you're syncing and run the script "Filter Records To Pull" by hand. You should be able to fine tune and debug your find request here, which is much simpler than debugging it from within a running Zync.

Tagging Found Sets.

You may want to mark records as having been downloaded, and in some cases record who downloaded them. This can be used as part of marking a record " checked out" and/or preventing such tagged records from being edited on the server while the mobile user has them.

To tag a record when it is being pulled down to a mobile device, use  custom field mapping and you'll see branches very similar to those discussed above in building found sets. For each table occurrence, create SetField steps that mark the records as you see fit.

Don't forget that you'll probably want to un-tag these records when they are synced back from the mobile device. You can do that in custom field mapping as well.

Passing filter criteria up from the mobile file

This feature was added in version 3.17 of GoZync and simplified in version 4 and 5.

As described above, the script "Filter Records To Pull" in your hosted file determines the found set which should be synced for each table. It is within this found set that we look for records changed since the last sync.

In some cases, you may want  your users to determine which records sync. For example, they may ask for records from a certain territory (selecting a different territory every time) and you'll want to include this criteria in the find requests you're building in "Filter Records To Pull".

To do this, edit the script "Specify User Defined Search Criteria (TOname)" in GoZyncMobile. You'll see some example steps where after a branch for each table occurrence we pass filter criteria to a sub script with this filter criteria as a parameter.

For example, if you had a global field called "Properties::SelectedTerritoryGlobal", the parameter for the subscript might look like:

List ( 
"Territory" ; 

Then your PerformFind() steps in the script "Filter Records To Pull" will have access to a variable named $Territory and you can use this variable as part of your find criteria.

Can I "push" just a found set of records up from my mobile device?

Yes. Checkout  Pushing Found Sets.


These steps should help debug most issues with filtering found sets.

1. Pick one table to sync.

2. Run the Toggle PSOS On/Off in your hosted file

3. Place a debugger break point in your filter script in the branch that matches your table

4. Run the sync with Debugger on. Keep moving it forward until you reach the Filter script where you placed the break point.

5. Carefully step forward one step at a time. Watch what happens when the Find step is performed. Did it produce the correct found set? If it didn't can you see the why it didn't.

Additional Tip: If the script debugger doesn't stop in the filter script and your hosted files are on a server. Then you didn't run the Toggle PSOS Script in your hosted file. If you think you did try testing the files on your desktop. Take them off the server and try again.