Select to view content in your preferred language

Batch Operations in ArcGIS for Power Automate

216
2
3 weeks ago
AkshayHarshe
Esri Contributor
1 2 216

Introduction

ArcGIS for Power Automate is a powerful tool that enables you to automate workflows by integrating ArcGIS with various services. One significant functionality is the ability to add data to feature layers. However, as your data processing needs grow, you might find that migrating to batch operations becomes essential to improve efficiency and manage larger datasets effectively.

What are the new batch actions?

In 2024.2 release we introduced Batch actions that allow us to add or update multiple features in a single request. The following actions are added to the list

  • Add records to a feature layer (batch)
  • Update records in a feature layer (batch)

These actions will take Array of Features as their input. Notice the difference between Update a record in a feature layer Inputs vs Update records in a feature layer (batch)

AkshayHarshe_0-1747952063158.png

 

AkshayHarshe_1-1747952063159.png

 

Appropriate JSON structure for the Array of features can be found here.

To extract the schema of your Feature layer, access the REST endpoint of your ArcGIS server service and query the features at "/server/rest/services/FeatureService/<layer>/query". For ArcGIS Online, open Item details for the layer you are trying to query under item details and view the URL.

AkshayHarshe_2-1747952063160.png

Once at the query endpoint form, under Where, use 1=1 (or an OBJECTID you know) with Out Fields set to * and Format set to JSON.

If your data originates from sources other than a feature layer, such as Excel or a database where geometry information is stored in a text column, you must rename the column to "geometry" for the Batch actions to recognize it in Power Automate. Alternatively, you can create the required JSON structure using Power Automate built-in actions like Select, Compose, and Parse JSON from Data Operations, which will be useful.

Here is a sample JSON structure.

[{
    "geometry": {"x": 1234,"y": 1234},
    "attributes": {"name1": "value1", "name2": "value2"}
  },
  {
    "geometry": {"x": 1234, "y": 1234},
    "attributes": {"name1": "value1", "name2": "value2"}
}]

Are batch actions right for you?

When working with single feature operations such as `Create/Update a record in a feature layer` you typically add one or a few features at a time to your feature layer. This method is straightforward and can be sufficient for small-scale data additions or updates. There is no need to change the existing workflow as there are no performance gains.

Using these actions within a "For Each" loop becomes less efficient when handling a large number of records that need to be created or updated. It is advisable to consider migrating to batch actions in the following scenarios:

  • Updating dozens or thousands of records.
  • The flow is set to run frequently with numerous features.
  • Working with feature arrays can be a better alternative to configuring each field in a form for single record actions, particularly when dealing with feature services that contain many fields.
  • Performing copy operations.
2 Comments
ckellow
Regular Contributor

Excuse my ignorance here as this is my first time really diving into Power Automate and the connectors for ArcGIS. How does the JSON structure work for the batch update? 

You pick your feature layer, then you pick the unique ID field. When creating your array of features, are you then using the geometry as the tie to the unique ID field and then updating the attributes according to which feature is being pointed to?

If you could maybe explain a tad more on the JSON structure and how that relates to the unique ID field that would be awesome for a beginner. 

Thank you for any and all assistance

AkshayHarshe
Esri Contributor

@ckellow Thanks for your question. I think maybe the example JSON isn't clear enough to understand this, hope following will clarify that.

In the Power Automate form for the action e.g. `Update records in a feature layer (batch)` requires you to choose the layer and the unique id field for that layer. According to the layer I am using in the screenshot above it it is `FID`. This is used to identify which features this batch action is going to edit and not the geometry. This means the attributes json must have the uniqueID field as a key value pair.

If it is a hosted feature layer then Unique id field is auto generated which could be FID/ObjectID or  GlobalID. In the JSON below I am editing the features with FID 1 and whatever the attributes/geometry I need to update.

[
  {
    "attributes": {
      "FID": 1,
      "objectid": 1,
      "name": "REDLANDS COMMUNITY HOSPITAL",
      "address": "350 TERRACINA BLVD",
      "city": "REDLANDS",
      "state": "CA",
      "zip": 92373,
      "ownership": "Government",
      "ntl_rate": "No Different than Natl Rate",
      "mortreadmi": 20.7,
      "total": 52,
      "latitude": 34.03667703,
      "longitude": -117.2038564,
      "admissiond": 1436572800000,
      "GlobalID": "f822cf31-60d3-426d-8589-1c1486b19739"
    },
    "geometry": {
      "x": -13047073.613499999,
      "y": 4033727.9189999998
    }
  }
]

 On a side note for you to use up Create, update, delete operation with ArcGIS actions in Power automate a feature layer must have editing enabled with Editor tracking on.

Contributors
About the Author
I am a GIS professional working with ESRI since 2013. I have a passion for location-enabled services how it is important in today's analytics of the data-driven world. I am privileged to work as a Product Engineer on the ArcGIS Insights team where I get to materialize my passion and build a product that is driven by cutting-edge technology in this industry. When I am not doing GIS you will mostly find me taking photos and talking about photography.