Select to view content in your preferred language

Configure an Editing Geofence in your Form using Arcade

1337
5
12-10-2024 08:17 PM
GlenShepherd
Esri Contributor
5 5 1,337

The Premise:

Currently, geofences only allow us to configure notifications or location sharing (tracking) for our mobile workers once they cross a certain threshold that we've specified and configured in the ArcGIS Field Maps Designer.

However, we may want to use a boundary polygon to restrict where mobile workers can or cannot perform edits.  Two examples of this might be:

  • Preventing data from being collected on private property
  • Restricting data collection to only occur within tenement boundaries

While this isn't out-of-the-box functionality within the 'Geofences' settings, we can use Arcade and conditional logic during form configuration to acheive the desired effect.

 

The Workflow:

The following example uses a web map with:

  1. A polygon feature layer (named 'PropertyBoundaries')
  2. An edit-enabled point layer (named 'Hazards')

When configuring the form for the edit-enabled layer, set a field to be *Required:

FMBlog1.png

 

Then, for the same field, click on the settings cog next to the 'Editable' logic to configure an Arcade expression:

FMBlog2.png

Name your expression something like 'Editable Geofence', then click on 'Launch Arcade editor', and use the following Arcade example as a guide:

 

var properties = FeatureSetByName($map, 'PropertyBoundaries')
var property = First(Intersects($feature, properties))
if (!IsEmpty(property)) {
  return true
} else {
  return false
}

 

This code block will be applied at the time of digitising a new point feature or performing an update to the geometry of an existing point feature in this layer.  In the Arcade sample above, we use:

  • the FeatureSetByName function to call the polygon layer in the web map and asign it to a variable (var) named 'properties'
  • We then use the First and Intersects functions to find the first feature in the polygon layer that our point intersects with and assign it to a variable (var) named 'property'
  • We then use an if statement to check if the 'property' variable is not empty (!IsEmpty), returning boolean values:
    • true - the field will be editable if the 'property' variable is not empty
    • false - the field will NOT be editable if the 'property' variable is empty

FMBlog3.png

Click on 'Run' to test your Arcade script and check if it spits out a 'true' or false' sample value. Then save your form in the ArcGIS Field Maps Designer.

The next step is to test the behaviour in the ArcGIS Field Maps mobile app.  In the GIF below, we drop a point outside the boundary polygon features and the form logic prevents our required fields from being edited, which prevents the point feature from being submitted.  Once we correct the point location to intersect a boundary feature, the required fields become editable and the new point can be submitted successfully:

FMMA1.gif

A few things to note:

  • Yes, this will work offline
  • Works best coupled with the appropriate collection settings for your project, configured via the 'AppSettings' tab in ArcGIS Field Maps Designer.
  • *Required logic doesn't work properly for fields that have been published from ArcGIS Pro with 'Allow Null' disabled.  The publishing process adds a default value of '0' (numeric fields) or " " (string fields) which allows "empty" submissions.  If you've already published fields configured this way, you can fix the schema and overwrite via ArcGIS Pro or use 'Update Definition' via the REST endpoint. Video example here: https://app.screencast.com/U2uZSZB0ztDDj
5 Comments
Contributors
About the Author
Esri Australia Client Success team member