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. 🤞
It was shown at UC also but not sure when its out?
This will be available with the 25.2 release of Field Maps later this year. We are currently targeting a fall release. Thanks!
The 'add' button in the slide deck doesn't allow for attributes to be passed through like the URL scheme does. The html pop-up links and new Tasks custom URL layout icons can leverage the URL scheme to add different types of related records with prepopulated data.
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.
@ColinLawrence are you able to share more information around this limitation? Does it apply to related tables only or does it include related layers?
We want to use relationships for pop-ups and forms and it's really difficult to identify what is supported and what the known issues are.
Hey @ChristopherCounsell , yes the limitation would apply to any form of relationship that is supported in Field Maps (feature-feature, feature-table, and more specifically when used in a 1-M relationship). What is happening is that when the URL is executed we are identifying the parent layer and feature called out in the URL, then using the key field to look up the relationship. At the moment there is no method to select which related layer to select if there are multiple so it defaults to the first one in the index. You can verify this order at REST by inspecting the JSON of the parent layer and look for
"relationships" : [
We hope to support a method to select a specific table/layer with addRelatedFeature in the future.
It was nice chatting briefly at the UC as well!
We cannot get this to work. I stripped it back to a point layer + related table. One relationship.
Relationships shown on layer 0
"relationships" : [
{
"id" : 0,
"name" : "Layer_Table",
"relatedTableId" : 1,
"cardinality" : "esriRelCardinalityOneToMany",
"role" : "esriRelRoleOrigin",
"keyField" : "GlobalID",
"composite" : true
}
],
Related table relationships shown on table 1:
"relationships" : [
{
"id" : 0,
"name" : "Layer_Table",
"relatedTableId" : 0,
"cardinality" : "esriRelCardinalityOneToMany",
"role" : "esriRelRoleDestination",
"keyField" : "parentglobalid",
"composite" : true
}
],
Arcade expression:
var itemID = 'xxxxxxxxxxxxxxxxxxxxxxxx'; // web map
var featureSourceURL = 'https://services7.arcgis.com/xxxxxxxxxxxxxxxxx/ArcGIS/rest/services/xyzxy/FeatureServer/0' // the PARENT servcice URL in map
var featureID = Lower(Replace(Replace($feature.GlobalID,'{',''),'}','')) // globalid of parent, tested upper, lower, encoded, with/out {}
var foreignKeyField = 'GlobalID' // 1:M is GlobalID:parentglobalid. Understand this is the key in the parent table, to lookup.
var referenceContext = 'addRelatedFeature' // add related feature
// var featureAttributes = UrlEncode(`{"Field":"value"}`); // tested with/out values
// concatenate values
var values = 'referenceContext='+referenceContext+'&itemID='+itemID+'&featureSourceURL='+featureSourceURL+'&featureID='+featureID+'&foreignKeyField='+foreignKeyField//+'&featureAttributes='+featureAttributes
var url = "https://fieldmaps.arcgis.app/?" + values;
return url
The above code gives no error but does nothing. Logs show '[APPINTEGRATION] [addRelatedFeature] failed to find relationship'.
The generated URL in the text pop-up appears to be valid.
That was tested in 25.1.0 on iOS 18.5, iPhone SE.
There are no issues adding related records via the related table button in Field Maps.
Testing the same map and arcade generated URL in beta 25.2.0 2206 on Android works perfectly.
Any ideas?