Select to view content in your preferred language

Arcade Button to Create Related Records

867
15
03-17-2025 04:01 PM
MappingMoose
Occasional Contributor

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

 

0 Kudos
15 Replies
ColinLawrence
Esri Regular Contributor

Hey @ChristopherCounsell , everything looks correct with your syntax which is reinforced by it working in the Beta version. What is happening in the app when the URL is called? Does nothing happen or does it select the parent feature and open the popup? I will try with some of our examples in the meantime.

Regards,
Colin
0 Kudos
ChristopherCounsell
MVP Regular Contributor

Thanks @ColinLawrence 

We have the pop-up open already of the parent feature, clicking the link does nothing. Just the message in the logs.

Other configurations when the syntax was incorrect threw error messages like can't find the GlobalID within the app.

We created the layer in ArcGIS Pro. Simple and Composite relationships tested.

Is there a sample map / template where this works?

Cheers 

Chris

0 Kudos
ColinLawrence
Esri Regular Contributor

@ChristopherCounsell So I got around to testing a few internal examples we have. Its possible there is a regression here. I found that an example I had with multiple tables was working (and hitting the first index table) but an example with only a single table in the service was not working and I am seeing the same message in the logging that you reported. Going to try and stand up something from scratch to double check but seems like a bug could have been introduced here. If so, I'm a surprised this was not reported already.
We dont have an external sample, just the example URLs in the doc which we can already confirm you have formatted correctly. 

Regards,
Colin
ColinLawrence
Esri Regular Contributor

I just confirmed the same links work in the iOS beta as well. So there is something that changed in the 25.1 version for iOS. 

Regards,
Colin
ColinLawrence
Esri Regular Contributor

Sorry for the deluge but, in case you want to get attached to this, there is a BUG number:

BUG-000175355 - When using a URL to open and create a related record on a point collected in ArcGIS Field Maps, the URL is no longer opening the related records pane.

Regards,
Colin
ChristopherCounsell
MVP Regular Contributor

Thank you so much! 

0 Kudos