GoZync4

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.

Here is how it works.

There is a single script in GoZyncMobile that controls bringing data down to a mobile device. The script is "Filter Records To Sync" and it 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 "Customers", performing a find that only grabs the active customers. Using simple FileMaker Finds like this, you can easily add sophisticated syncing behaviors to GoZync.

Filtering in Action

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

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 Zync" 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. 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 Zync" 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.

As described above, the script "Filter Records To Zync" in GoZyncMobile 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) or you may simply need to include some fact about the mobile file (maybe the user's ID) in the find requests you're building in "Filter Records To Zync".

Remember, GoZyncMobile has access to any global fields in your mobile files. So these are easily used in find requests within the GoZyncMobile script "Send Filters to Pull".

Edit that script and you'll see a comment to "Specify user-defined search criteria" for the pull, It's easiest to write any criteria you need to a local $variable so you can use them in the PerformFind() steps that follow. For example, if you had a global field called "gzm_Properties::SelectedTerritoryGlobal", your calc might look like:

SetVariable [ $territory ; gzm_Properties::SelectedTerritoryGlobal ]

Then your PerformFind() steps can use this variable as part of your criteria.

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

Yes. Checkout Pushing Found Sets.

Controlling Filters Server Side

GoZync executes its filters in GoZyncMobile (the script "Filter Records to Zync" is IN GoZyncMobile). So you can't change your filter criteria without distributing new mobile files.

If you need to change filters without distributing new files, it's actually pretty easy to set up before you distribute your first mobile file:

Create a "flag" field in the hosted table you'd like to filter. Do not add this to your sync layouts in GoZyncMobile.
Make this flag a calc that is true (returns a 1) if the logged in user should get that record in their sync.
Change the script "Filter Records to Zync" in GoZyncMobile so that it just searches for this flag field containing a 1.

This lets you embed all your filter logic in a calc in your hosted file, so you can change it on the fly. The down side is that you're probably searching on an unstored calc (your "flag" field) and that's not as fast as searching on indexed fields. You can use the split times in GoZync's logs to see how much of your sync speed is being take up by this find.

(855) SEEDCODE
[email protected]
Follow us: