Hi All,
I've recently been looking to create a workflow where field users can create a related record in Field Maps by tapping one button in the pop-up of the 'parent' asset. I watched this video: ArcGIS Field Maps: Advanced Workflows with Arcade - Esri Videos: GIS, Events, ArcGIS Products & Indu... and attempted to set this up using Arcade.
I had a few errors about keys at first when I hadn't copied the syntax correctly, but currently when the button is tapped in the map pop-up there aren't any errors, but it just refreshes the already open pop-up for the selected feature.
I was a bit confused about the Arcade syntax as it only refers to the parent feature and there isn't anything to refer to the related layer or table from what I can see. My feature service has several layers in it that are related to each other. The workflow is basically: a field worker might be on a walking track, then plot a picnic area related to that walking track in one layer, and then plot a communal barbecue in another layer that is related to both the walking track and the picnic area.
I read this community post: Solved: Create direct link to add related records in Field... - Esri Community, and my thoughts are similar to Leigh Starr's comment. It is unclear (to me at least) how this can work with multiple related layers.
I then read this community post: Solved: AddRelatedFeature Url Parameter Error: Foreign key - Page 2 - Esri Community and Colin Lawrence mentions it only working for the first table in the service? I wasn't entirely sure.
All of that to say - is it possible to use these URLs when there are multiple different relationships between layers? Is there something else I can do with a FeatureSet maybe?
I'll paste the Arcade from ajohnson_wsb's post here as this is what I have used.
var itemID = //item id of web map;
var featureSourceURL = //feature service url of parent asset
var featureID = Replace(Replace($feature.GlobalID, "{", ""), "}", "") //globalid field of parent asset, with stripping of curly brackets
var foreignKeyField = 'GlobalID' //globalid field of parent asset
var referenceContext = 'addRelatedFeature'
var values = 'referenceContext='+referenceContext+'&itemID='+itemID+'&featureSourceURL='+featureSourceURL+'&featureID='+featureID+'&foreignKeyField='+foreignKeyField
var url = "https://fieldmaps.arcgis.app/?" + values;
return url
At Dev Summit they showed a whole new way to add related records that seems much better. I think it is 1 click now.
Bad pic but you get the idea. Not sure the exact time but I think next release. May be worth checking that out.
That UI looks very handy. I hope it supports features with multiple relationships. 🤞
Yes we hope the next release this summer (or shortly after) will support the related element in popups, which gives a lot more freedom with your experience with related tables in Field Maps.
@MappingMoose addRelatedFeature URLs do have a limitation if there are multiple related tables in the service that use the same key. If there are multiple tables, it will default to the table with the lowest index number (e.g. /1). We have heard this feedback and hopefully can improve in this area in the future.