AddRelatedFeature Url Parameter Error: Foreign key

1372
13
Jump to solution
08-01-2023 06:35 PM
LuisaC
by
Emerging Contributor

"Unable to Update Feature

The specified foreign key field couldn't be found."

I've been running into this error when attempting to add a related feature via url from a popup in my maps. The popup is on a polygon layer which is related to a point layer - both are in the same map, both layers are editable, and my foreign key field parameter is definitely the correct field name from the point layer.

I'm a little unsure of what might be causing this and I couldn't find much documentation surrounding the addRelatedFeature field maps parameter - anyone know what might be causing this error?

13 Replies
RowanTolfts
New Contributor

Hi Colin, that's a shame; glad to hear that it's being investigated by the team. Thank you for your help regardless!

0 Kudos
DanMakridakis
Regular Contributor

Colin, is there any way to push values into fields for the new related record via the URL? I know this can be done for URLs that launch Survey123 using Field:fieldname=value but this doesn't seem to have any impact when used with the related records in field map URL.

 

Solved!

Never mind, I found the solution in the documentation: 
Field Maps - Deploy your map (Open your map from a link)  - found under "Initiate updating a feature" section

 

Sample of the expression used to correct curly brackets and include feature attributes, I added colors to help others see the different parts (%22 is html encoding for double quotes):
"https://fieldmaps.arcgis.app/?referenceContext=addRelatedFeature&itemID=0c900ae2a1084d27b608233921ef1a84& featureSourceURL=https://services9.arcgis.com/QjGvjfQhsHAmqfjP/arcgis/rest/ services/DamageAssessment_Apr2018_631d0895e7d3404bb78e8e04e92d896e/FeatureServer/ 1&featureID="+Replace(Replace($feature.globalid,'{',''),'}','')+"&foreignKeyField=globalid&featureAttributes={%22incidentid%22:%22527%22,%22inspector%22:%22Frank Jones%22,%22inspdate%22:1502917218285%22}"

This expression is then used as the link URL in the pop-up text box content:
<p>
             <a href="{expression/expr0} ">Add Inspection</a>
</p>

0 Kudos
FeichiShih2
New Contributor

Hi Colin, Is it possible to pre-populate the geometry in FieldMaps by passing in the geometry in the URLparameters when referenceContext=AddRelatedFeature (Similar to how addFeature and updateFeature works)?  This would be really helpful.

 
0 Kudos
ColinLawrence
Esri Regular Contributor

Hi @FeichiShih2 , just to clarify, is the related feature you are trying to add another feature layer (not a table)? ie you may have a Feature to Feature relationship? Hypothetically it should be possible but I have not tried it. What happens when you use a link with geometry added in?

Regards,
Colin
0 Kudos