The Original FileMaker Community
Business Templates - Demo Apps - Video Tutorials -Samples - Help - 46000 Member Forum

The Leading Filemaker Developer Tools

Filemaker Go Tip – Checking for an Internet Connection – FileMaker Today

Get real time updates directly on you device, subscribe now.


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; “http://amiconnectedtotheinternet.com/” ] [ 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” ]

Else

Exit Script [ Result: “FAIL” ]

End If

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More