integrating two layers into capture field arcade expression

184
3
Jump to solution
2 weeks ago
Labels (1)
MM598
by
New Contributor III

Hi. I would like to write Arcade code that integrates two different layers. Data Collection (DC) Layer will be where photo and attribute data goes. Location Source (LS) layer will have FSA Farm/Tract/Field data that will auto-populate based on the location of the photo taken and this photo and the corresponding capture fields will be saved in the DC layer.

I notice that in the data tab of the button editing pane, only one target feature layer can be added. Is it possible to write Arcade code that will fill in FSA Farm, Tract, and Field numbers into Capture Fields based on location of the photo?

Note that DC is a point layer, LS is a polygon layer.

0 Kudos
1 Solution

Accepted Solutions
JohnathanHasthorpe
Esri Regular Contributor

Apologies, in that case, you just need to add the LS layer to a web map and set it as the QuickCapture project map.

You can then use $map to reference the LS layer by name.

Here is an example that grabs the Regions polygon layer in the project web map and uses it for an intersect between it and the captured feature ($feature). It returns the region name for the intersected polygon:

// Create a feature set using the 'Regions' layer in the map
var regions = FeatureSetByName($map, 'Regions', ['name']);

// Intersect the current location with the regions and
// get the first region
var region = First(Intersects($feature, regions));

// If the current location does intersect a feature,
// return the name of the region. Otherwise, return null
if (HasValue(region, "name")) {
return region['name'];
} else {
return null;
}

You should be able to modify the above by updating the layer name ('Regions') and returned field ('name' and "name").

Let me know how you go.

Thanks

John

 

 

 

 

 

View solution in original post

0 Kudos
3 Replies
JohnathanHasthorpe
Esri Regular Contributor

Hi - Unfortunately, the arcade expression can only update the field/layer it has been configured for. The functionality is inteneded to provide more flexibility when updating a single field and can't be used to update multiple fields in the target or additional feature layers.

The best option for your requirement would be to look into web hooks: https://www.youtube.com/watch?v=2cYsa6xsxqk - here you could build a scenario that queries and updates multiple layers.

Further information:

https://doc.arcgis.com/en/quickcapture/help/webhooks.htm

 

0 Kudos
MM598
by
New Contributor III

Hi Johnathan. I actually only need to update one field in one layer (DC). The other layer (LS) does not need to be updated, but it would be used as a data source. The Arcade code would use the polygons in LS to see which intersects with the point in DC, then a field in DC would be updated.

0 Kudos
JohnathanHasthorpe
Esri Regular Contributor

Apologies, in that case, you just need to add the LS layer to a web map and set it as the QuickCapture project map.

You can then use $map to reference the LS layer by name.

Here is an example that grabs the Regions polygon layer in the project web map and uses it for an intersect between it and the captured feature ($feature). It returns the region name for the intersected polygon:

// Create a feature set using the 'Regions' layer in the map
var regions = FeatureSetByName($map, 'Regions', ['name']);

// Intersect the current location with the regions and
// get the first region
var region = First(Intersects($feature, regions));

// If the current location does intersect a feature,
// return the name of the region. Otherwise, return null
if (HasValue(region, "name")) {
return region['name'];
} else {
return null;
}

You should be able to modify the above by updating the layer name ('Regions') and returned field ('name' and "name").

Let me know how you go.

Thanks

John

 

 

 

 

 

0 Kudos