Filemaker Go Tips - Checking for an Internet Connection - Anvil Dataworks Anvil Dataworks

Filemaker Go Tips – Checking for an Internet Connection

October 8, 2013 by Mike Beargie

Accounting for a stable network connection in Filemaker Go is an important step to avoid confusion and frustration from mobile users. Filemaker gives developers a few tools to check in the background for a network connection. With some basic error detection and creative file setups, developers can easily detect a network connection and proactively action their scripts. Let’s explore a few scenarios where detection would be helpful.

Scenario 1 – iOS user syncs data from local file to Filemaker Server
This is a common scenario, where a developer has already removed a constant network connection as an issue by having data stored on the user’s iOS device, with a sync utility built to pull/push data to a hosted server file. There are many good utilities out there for performing these syncs, but you can go a step further by proactively checking for a network connection before running the sync.

For this type of solution, the following setup steps are usually taken:
1) The connections to the remote database are stored in a separate local “sync” file.
2) A script in your main local file is tied to run the “sync” from the separate file.
3) On the “perform sync” script in the main file, a network check is done before calling the sync file script to perform the sync.

Scenario 2 – iOS user connecting to remote file
Many developers still use the “out of the box” abilities of Filemaker Go to open files that are hosted on a remote server. As an alternative to directly opening the file, developers can setup local “opener” files that first check for the connection, or even check to see if the remote file is hosted and available. After error checking, the script in the opener file either silently opens the file, or prompts the user with an error.

For this type of solution, the following setup steps are usually taken:
1) The “opener” file is configured to auto-login and perform the opening script.
2) Error checking is written into the opening script.
3) The “opener” file is added locally to each user’s iOS device, with any profiles or shortcuts to have the user launch that file.

Scenario 3 – iOS user using features requiring a network connection.
When a user on Filemaker Go is using features of Filemaker that require an internet connection, it is important to make sure they CAN use those features. For example, a web viewer with a google map, or sending an email update to someone from the field.

Developers can account for this scenario by performing a check as part of their navigation script that takes the user to a layout, or as a check on any button in the Filemaker Go solution. Storing the check as it’s own script, then calling it using the “Perform Script” script step is an easy way to integrate the check throughout your file.

Performing the Error Check
Filemaker 12 introduced the “Insert From URL” script step. This script step can be used in a variety of different ways, but at it’s core, will insert the code from any website into a text field. More importantly, Filemaker also has an error code, #1631 that indicates “Connection failed”. So when you try and Insert From URL, and do not have a network connection, error #1631 is returned.

Your error checking script might look something like this:

Set Error Capture [ On ]
Freeze Window
Go to Layout [ “CheckHere” (CheckTable) ]
Enter Browse Mode
Show All Records
If [ Get(FoundCount) = 0 ]
New Record/Request
End If

Insert from URL [ CheckTable::CheckTextField; "" ] [ Select; No dialog ]

#First Error Checkpoint
If [ Get(LastError) = 1631 ]
Exit Script [ Result: "FAIL" ]
End If

Set Variable [ $text; CheckTable::CheckTextField ]
Set Field [ CheckTable::CheckTextField; "" ]
Go to Layout [ original layout ]

#Exit the script with a second error checkpoint
If [ PatternCount($text ; "Yes :)") > 0 ]
Exit Script [ Result: "SUCCESS" ]
Exit Script [ Result: "FAIL" ]
End If

Further Reading
Filemaker’s pages on Insert From URL, Error Code Reference Guide, and the Filemaker Go 12 Development Guide.

Looking for help with your Filemaker Go solution? Anvil Dataworks has a team of certified experts that can take your solution to the next level! Contact Us to get started!

1 Comment »

  1. […] More… Anvil – Blog. […]

    Pingback by Filemaker Go Tips – Checking for an Internet Connection - FileMaker Pro Gurus — October 9, 2013 @ 11:41 am

RSS feed for comments on this post. TrackBack URL

Leave a comment