AddRelatedFeature Url Parameter Error: Foreign key

913
11
Jump to solution
08-01-2023 06:35 PM
LuisaC
by
New Contributor II

"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?

1 Solution

Accepted Solutions
ColinLawrence
Esri Regular Contributor

Hi @LuisaC , what key fields are you using for your relationship? Is it a GlobalID -> GUID or are you using your own fields?

Have you tried using the key field from the "parent" layer? I understand this can be a little confusing but as the point of entry, and what you are editing in this scenario, is the related "child" feature it would then be the "parent" layer which is the foreignKeyField. Therefore if you are using GlobalID -> GUID relationship the foreignKeyField would be GlobalID. Give this a shot and let me know if you still get an error. 

Regards,
Colin

View solution in original post

11 Replies
ColinLawrence
Esri Regular Contributor

Hi @LuisaC , what key fields are you using for your relationship? Is it a GlobalID -> GUID or are you using your own fields?

Have you tried using the key field from the "parent" layer? I understand this can be a little confusing but as the point of entry, and what you are editing in this scenario, is the related "child" feature it would then be the "parent" layer which is the foreignKeyField. Therefore if you are using GlobalID -> GUID relationship the foreignKeyField would be GlobalID. Give this a shot and let me know if you still get an error. 

Regards,
Colin
LuisaC
by
New Contributor II

That does appear to be the solution - thanks a ton!

0 Kudos
DustinHorn2
New Contributor II

Could I see a good example of using this parameter? I am trying to create a related record using the addRelatedFeature but can't seem to get it working. I'm sure I'm missing one little thing. My URL looks like:

https://fieldmaps.arcgis.app?referenceContext=addRelatedFeature&itemID=9b009b91e54342ce84bb9af179f71...

EDIT: The only difference I see is that when I click this url inside of field maps it sends the GlobalID in uppercase whereas the link generated through webmapviewer the GlobalID is in lowercase. Using the link with lowercase GlobalID works. Why is field maps sending uppercase and is this what's causing issue?

0 Kudos
ColinLawrence
Esri Regular Contributor

Hey @DustinHorn2 , can you add some context about how you are using this URL? Is it from a popup in Field Maps and you are attempting to launch directly into a related record collection (perhaps in another map or layer)? Is the globalID parameter that is being "converted" the one in brackets or are you referring to the value for the foreignKeyField? I believe if its the one in brackets, ie pulling the globalID value from the table, then this would be a known issue. 

Regards,
Colin
0 Kudos
DustinHorn2
New Contributor II

Hey @ColinLawrence,

Thank you for responding. I am using the URL inside fieldmaps to call an inspection through the popup to reduce the amount of clicks to get to the related table. You're correct in that the issue lies with the GlobalID in brackets. Fortunately, I have a workaround that seems to work by using arcade to strip off the brackets that are passed in the URL. Now I am getting a clean GlobalID. I should have thought of this before. 😊

ColinLawrence
Esri Regular Contributor

Thats great! We do see the need to be more consistent across the platform with how the GlobalID field is handled. 

Regards,
Colin
0 Kudos
DanMakridakis
New Contributor III

Thank you Dustin! Until I saw this I couldn't figure out why the URL wasn't working. I then had it return the URL as text in my pop-up and realized that field maps was adding the curly brackets to the globalid (while map viewer wasn't). A custom expression with a Replace function solved it!

0 Kudos
RowanTolfts
New Contributor

Hi Colin, thanks for your help with this issue! I've got a feature layer with multiple related tables, and I've got the link working in that it opens the form for a new related record in one of the tables. Do you know if there's a way to specify in the URL parameters which table to add a record to?

0 Kudos
ColinLawrence
Esri Regular Contributor

@RowanTolfts I believe it will default to the table that comes first in the service index given they share the same key field. Right now there is no way around that as far as i'm aware. I believe its something the team is investigating for the future. 

Regards,
Colin