ArcGIS Blog

Field Operations

ArcGIS Field Maps

Automatically create Workforce assignments after an inspection

By Aaron Pulver and Josh Clifford

A common use case we hear from customers is creating follow-up tasks in ArcGIS Workforce after an inspection has been completed with ArcGIS Field Maps. In this blog post, we’re going to walk through how you can use the Field Maps Integromat app to watch for new hydrant inspections and then create any necessary Workforce assignments — all without writing any code.

Create the hydrant inspection layers and map

First, you’ll create the hydrant layer and map used to perform the hydrant inspections in the Field Maps mobile app. Sign into your ArcGIS Online account.

Note: The Field Maps module in Integromat is not currently supported on ArcGIS Enterprise.

On the Content tab, click New item.

Add new item

Click Feature layer, then select Use a template and click Next. In the Create a feature layer window, search for and select Hydrant Maintenance Inspections.

Hydrant Maintenance Inspections

Click Next and follow the instructions for creating the layer. Use all of the default options and provide a title of “Hydrant Maintenance Inspections.” After you click Save, the layer and table are created and added to your content.

On the item details page of the new layer, click Open in Map Viewer using the drop-down menu.

Open in Map Viewer

Map Viewer opens with the Hydrants layer and Hydrant Maintenance Inspection table.

Map Viewer

Click the Save and open action and then choose Save. Enter a Title of “Hydrant Maintenance” and click Save map.

Next, create a sample hydrant feature that we’ll use later in the Mobile app (in a production scenario, the hydrant assets would likely already exist). Click the Edit action.

Edit features

Choose Add feature. Then click somewhere on the map to add a new hydrant feature. Fill out the form and click Add.

Add hydrant

Create the Workforce Project

Next, you’ll create the Workforce project used to assign work based on completed inspections in Field Maps. Open the Workforce web app using the app launcher.

 

Open Workforce

Click Create Project. Enter a name of “Hydrant Repairs” and then click Create project.

Once the project is created, add four assignment types:

  • Install Chains
  • Install Marker
  • Lubricate
  • Paint

Once you create your project and add the four assignment types, you’re ready to create the scenario in Integromat. For more information about creating Workforce projects, see Create a project.

Create the Integromat Scenario

Browse to Integromat.com and create an account if you haven’t already. Once you sign in, click Create a new scenario to get started.

Click on the large icon to start building the scenario. Search for “Field Maps”. Click ArcGIS Field Maps to use the Field Maps app. Select the Watch Features module.

Watch features

On the webhook configuration dialog, click Add to start configuring the webhook that will watch for new inspections.

Fill out the following information:

  • Webhook name—Provide a name for the webhook that is unique to the project or map you’re configuring the webhook for.
  • Connection—Click Add to connect to your ArcGIS account. Type ‘ArcGIS’ for the connection name. Set the sub-domain to be “services{env}” where {env} is the optional environment number where your organizations data is hosted. You can find this by navigating to the Hydrant Maintenance Inspections feature layer in ArcGIS Online and inspecting the URL. We’ll use this same connection for some Make an API Call modules later.
Services URL

Click Save to register the webhook with ArcGIS Online. Then click OK to finish configuring the Watch Features module.

Next, you’ll add an Iterator module. This allows the webhook to iterate through an array of features if multiple features are returned at once. For example, if multiple mobile workers add new inspections around the same time, an iterator ensures each inspection is processed.

In the Tools section, click Flow Control.

Flow control

From the list of options, select Iterator. The Iterator module is automatically added to the webhook and connected to the Field Maps module.

Click in the Array text box and then using the dropdowns find  Adds[] under the Hydrant Maintenance Inspections (1) table. This is the array of new features to iterate over.

Iterator configuration

For each of these inspections, the parent hydrant feature needs to be queried so that the Workforce assignment can be created at the same location as the hydrant.

Select the Field Maps app again; it’s located under Favorites now.

Integromat favorites

This time choose the Make an API Call module and connect it to the Iterator.

For the URL enter the relative path to the Hydrants layer. You can copy the full URL from the item details page again. Make sure you remove the host and domain from the URL and that it’s using layer id 0 (Hydrants).

Next, add four Query String parameters (shown below) so that the returned data is in JSON format, has all of the fields within the layer, uses the Web Mercator projection, and will only query a single hydrant. Click OK.

Query Hydrants

Next, the response from this query needs to be parsed. Search for the JSON app and then select the Transform JSON transformer. Connect this to the Make an API Call module.

Set the Object to the Body of the previous module.

Transform query response

Search for the JSON app and then select the Parse JSON transformer. Connect this to the previous module.

Set the JSON string to the JSON string of the previous module.

Parse hydrant query

Click Add to add a new data structure. This defines how the JSON response from the query should be parsed. Click Generate to generate the data structure from a subset of the query result. An example is provided below.

Note: These two JSON modules are used to transform a generic object to a string then to an object with a specific data structure. This makes it easier to use in future modules by providing an output interface – it’s not strictly necessary to do this though. You can run the partial scenario to get the output interface of the Make an API call module.

Next, add a Router module from the Tools section and connect it to the previous Parse JSON module. The Router will allow different actions to be performed based on the inspection.

At this point the scenario should look like:

Partial scenario

Next, the hydrant and the inspection are going to be used to create a Workforce assignment feature. Add a new Create JSON module and connect it to the router. Click Add to add a new Data structure. This time use the following JSON which represents a generic Workforce assignment feature:

A form appears containing containing all the fields a Workforce assignment needs.

For the geometry,   the geometry of the previously queried hydrant to the x and y inputs. Set the spatial reference to Web Mercator.

Assignment geometry

For the attributes, set the status to ‘1’ (unassigned). Set the priority to ‘1’ (low). For the location, map the LOCDESC of the hydrant feature. Set the duedate to be 5 days from the time inspection was completed. This must also be formatted to use milliseconds from epoch.

Finally, the assignmenttype must be set to the GlobalID of the “Install Chains” assignment feature. This value is located on the Data tab on the item page for the Assignment Types table. When looking at the Table, click the Options menu and click Show/Hide Columns. Select GlobalID to display this value for each assignment. Copy the GlobalID for the “Install Chains” assignment type.

The assignment types table

The form should look like this:

Assignment attributes

Click OK to complete the form.

Next add another ArcGIS Field Maps Make an API Call module to the scenario and connect it to the previous Create JSON module. The module is going to create the assignment in the Workforce assignments feature layer.

For the URL enter the relative path to the Assignments layer. You can copy the full URL from the item details page of the Workforce feature service. Make sure you remove the host and domain from the URL and that it is using layer id 0 (Assignments).

Next, set the Method to POST.

Change the Content-Type header to application/x-www-form-urlencoded

Set the Body to f=json&adds=[]

Between the square brackets, map the JSON String from the previous module so that the assignment will be sent to the feature layer.

Create Workforce assignment

Click OK.

The “Install Chains” assignment should only be created if the inspection indicates that chains are required. To accomplish this, add a filter between the Router and the Create JSON module. Click the wrench icon between them and click Set up a filter.

Add filter

Set the Label to “Requires Chains”. Set the condition to use the “Chains Req’d? (CHAINS)” field and compare it to the value “Yes”. Click OK.

Create a filter

The basic scenario is complete and ready for testing. To create other types of assignments, additional routes can be added to the Router along with a different filter. Here’s what the final scenario should look like:

Full Scenario

Test the scenario

Click Run once to start the scenario. It will now be watching for a new Hydrant Inspection. In the Field Maps mobile app, open the ” Hydrant Maintenance” map. Tap on the hydrant feature. Tap to add a related record. Tap Add and fill out the form. Make sure you set the “Chains Req’d” attribute to “Yes”. Submit the feature.

Submit an inspection

In Integromat you should see the scenario execute within 30 seconds or so. After it completes, switch to the Workforce dispatcher web app. There should be a new unassigned assignment!

This is one way to use the Field Maps module to complete an end-to-end workflow. You could extend this in so many ways! See the Automate Field Maps topic for more information.

Share this article

Subscribe
Notify of
2 Comments
Oldest
Newest
Inline Feedbacks
View all comments
Tobias Fimpel(@fimpe001_uservices)
December 1, 2022 6:50 am

Russell, can you share any information on plans to enable this for Feature Layers that are not “hosted” but are “registered” ArcGIS Server services? Is there a realistic chance of that happening? That would help us plan ahead. Great blog post, thank you.

Ryan Bohan(@ryanbohan)
December 1, 2022 10:23 am

How will Full-Text Field Indexes work for feature layers we do not own? If an index is created when the search is added, assume you need to be the owner of the feature layer.

What is the feature layer is either a Living Atlas layer, or another agencies rest service. What is the best way to add a search to those layers?

Ryan Bohan(@ryanbohan)
December 1, 2022 11:02 am

Thank for for the fast response.

For the non-index cases does the lack of leading wildcard mean you are unable to search “Baltimore Post Office“.

When the full name is “Highlandtown Station Baltimore Post Office”, previously we have used contain for this, recently have seen some issues with the search results.

Last edited 2 years ago by Ryan Bohan
Ryan Bohan(@ryanbohan)
December 1, 2022 11:28 am

Awesome, great to know thank you.

Ryan Bohan(@ryanbohan)
April 26, 2023 1:45 pm
Reply to  Ryan Bohan

I wish there was an option to automatically add the “%” in the search configuration options. The general public would not think to add it if they are just trying to find a Post Office.

Adding the indexing is only an option, if I own the data.

Jeannette K Byrd(@tuscco)
December 5, 2022 6:02 am

Is this something that is implemented automatically when we create a hosted feature service? Also, you mentioned Instant Apps and the application settings of a web map – is there documentation on how to do this in the settings of a web map? What about Experience Builder?

Geraldine Eggermont(@go_fmis)
December 6, 2022 12:15 am

The Search widget doesn’t work in our maps since the November release. Or it works as ‘starts with’ while the search is configured as ‘contains’. I could repair this in a few maps by deleting/re-adding the search on layer settings, but this trick doesn’t work with most maps. This is really annoying and confusing for our users, is it meant to be so? This is not documented, and our local distributor didn’t seem to be aware of the problem neither. Are we really the only ones experiencing this?

Geraldine Eggermont(@go_fmis)
December 7, 2022 8:20 am

Hi Russell, the first option doesn’t work in most cases, so I’d like to hear about the second one, thank you.

Geraldine Eggermont(@go_fmis)
December 9, 2022 2:53 am

It just doesn’t work with a layer with views, I can’t use addToDefinition.

Error message:

Unable to add feature service layer definition. Not supported. Schema changes are not allowed for service. 

Adding the index works for another layer without views, I can see the index is added when printing the properties, but the search still doesn’t work in the map, even after deleting the map’s search conditions – saving – re-adding the search conditions.

So what do I do now? This really sucks, the search widget was working perfectly before, this is not an enhancement but a regression for us.

Geraldine Eggermont(@go_fmis)
December 9, 2022 6:39 am

Hi Russell, I have a ticket logged with my local distributor since 25 November (#03206890). They say they’re in touch with Esri US. Do you have access to it?

Geraldine Eggermont(@go_fmis)
December 9, 2022 7:42 am

I’m not using the views. But the feature layer I’d like to update (and can’t) has related views.

Geraldine Eggermont(@go_fmis)
December 9, 2022 7:44 am

And anyway, the search still doesn’t work with a layer with a full text index successfully added.

Geraldine Eggermont(@go_fmis)
December 9, 2022 7:51 am

I said it doesn’t work with a layer with views. How could I give you access to the maps and layers?

Geraldine Eggermont(@go_fmis)
December 9, 2022 8:08 am

I’ve invited you to a group with the maps and layers, but not sure how I can add them to the case. And should I keep on writing here, or via the case, or email?

Geraldine Eggermont(@go_fmis)
December 9, 2022 9:02 am

OK, done. Thanks!

Dylan Kennard(@dylan-kennard_oga)
September 25, 2023 2:15 pm

9/25/2023 – Russell I have enabled search on my “Web Map”. This then automatically as noted in documentation enables that search in the “Field Apps”. I see documentation that says it also instantly enables that search in the new apps. I have an “Instant – Side Bar App” and the search bar shows my configurable words from the “Web Map” in that App where I put “Hint Text – Search My Data” but nothing returns. Is there still some disconnect? I wanted to avoid configuring the search in the “Instant – Side Bar App”

Dylan Kennard(@dylan-kennard_oga)
September 25, 2023 2:19 pm
Reply to  Dylan Kennard

Solved it: In the “Instant – Side Bar App” I had to enable “Search Configuration – All Sources”. Otherwise it was just searching my top layer.