Skip to main content

Checking out Records

Can I mark records as "checked out" records so only the mobile user can edit them?

Absolutely. In fact, this is one of the most useful workflows GoZync enables. Note that checkout is not supported in the free version of GoZync, but it is in the GoZync Demo.

What checkout looks like.

When users pull records down from your hosted solution, the record is marked as "checked out". You can simply set a field called "out" to 1, or record something more elaborate, perhaps including the name of the user who downloaded it and when they did so.

(Remember, users can  download just their own records, so it's not like it would be a surprise who downloaded the record, but seeing the name can give you an extra sense of reassurance, and can remind staffers – who may not know all the business rules – who owns which records.)

You'd then enforce the checkout--and lock the record--by crafting access privileges in your hosted solution that prevent checked out records from being edited. This is great because users on the hosted solution (users "in the office") can edit records up until the moment a mobile user checks them out. Imagine: updating trouble ticket details up until the moment a mobile technician actually begins heading to the customer's location, but being prevented from changing it after that. Users in the office would then know they need to call the mobile technician to communicate any new details about the now checked out ticket.

Once the ticket is resolved and the mobile user syncs their updated ticket back to the hosted solution, the ticket is "checked back in" and is now editable again by users in the office.

Checkout in Action.

Watch this   short video of checkout in action, along with a walkthrough of how we do it.

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

How to implement it.

Getting this working in your solution is pretty simple. Reading up on downloading found sets will help give you some context for the changes that follow. You'll also use Custom Field Mapping to implement this, so read up on that as well (custom field mapping is one of the most powerful features of GoZync).

Checking out. Create a "checked out" field in your hosted solution. Feel free to add this to layouts, but don't add it to the layout used for zyncing in GoZyncMobile.fmp12 as there won't be a matching field on the mobile side. Create a branch in the script "Custom Field Mapping: Transformation and Hooks" for your table-- you'll create a branch for both the push and the pull, that is for both "gzm_YourTable" and "gzh_YourTable".

In the "pull" branch--the one based on "gzh_YourTable"-- set your checked out field to a literal value like "1" like this:

SetField [ gzh_YourTable::checked_out ; 1 ]

In the "push" branch--the one based on "gzm_YourTable"-- you'd then clear your checked out field or set it to a literal value like "0" like this:

SetField [ gzh_YourTable::checked_out ; 0 ]

Not that in both the push and the pull it is the  hosted record we're editing when it comes to checkout. This may be a little different than other SetField() steps you have going on that script where on the pull you're often setting fields in mobile records.

Last Zync Time If you're pulling records that are tagged as "scheduled" or "ready", for example, you want to sync based on that,  regardless of last sync time. The script "Filter Records To Pull" has an option to disregard this per table, those lines are disabled by default: you'll likely want to re-enable them when doing checkout.

Your Filter Criteria. In our example file (WorxHosted) you'll see that we mark a record with a status of "Scheduled" when it's ready to go down to the iPad and with "Checked Out" when it's been pulled. Our filter criteria in the script "Filter Records To Pull", however, pulls records of  both statuses. The reason is that if you only pull "Scheduled" items, GoZync will consider those as the only ones that should be on the iPad... and will  delete the ones marked Checked Out from your device. So it's best to think of the find requests as the criteria for the records that  should be on your iPad, not just the new ones you want to  get to your iPad.

Preventing Edits of Checked Out Records. In your hosted solution, use FileMaker's built-in access privileges to prevent editing of records where "checked out" is not empty (or zero). In relational solutions you'll want to apply this restriction to child records as well: one should not be able to edit an invoice line item if the invoice is checked out, for example.

That's all. Pretty cool, isn't it?