I have a feature layer with like 6 relationship classes in it, one of which i need to correct the foreign key. This feature layer has like 4 views and is apart of many apps, maps, surveys etc so overwriting would cause some issues.
It turns out I made a mistake with one of the 1:M feature layer: table relationship classes. I used the wrong field for the foreign key. This related table is actually empty and has been mostly been irrelevant, but I now have some data to load.
How can I correct this without download as a fgdb and totally overwriting the whole service? I have a lot of popups and form arcade expressions I would be so sad to lose. This is hosted in ArcGIS Online.
I hope you're having a good day! Based on what I found, the supported workflow is to update the relationship in ArcGIS Pro and then overwrite the hosted feature layer. However, relationships can also be added or removed through the REST API by modifying the layer's service definition.
Since your related table is already configured and you only need to change the foreign key field, it may be worth investigating whether the service definition can be updated directly instead. That said, this is not an officially supported workflow. There is room for error, and you could potentially break your data, so I strongly recommend testing it on a copy first.
I've attached an image showing what these relationships look like within the layer's definition. The keyField property contains the foreign key information you would want to update. Once again, because this workflow is unsupported, there is very little documentation available. My assumption is that if a relationship can be added or removed by adding onto the service definition, it may also be possible to modify an existing one in the same way.
The most relevant information I found on this was in an older Esri Community post where a user successfully added a relationship using this approach. One important detail they noted is that the changes had to be made to the definition of each individual layer rather than to the service definition as a whole.
I hope this is some helpful food for thought. Going through ArcGIS Pro is what is recommended; it is safer, albeit inconvenient, but I wanted to let you know this seems potentially possible as well. 🙂