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 & Industries 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