Deleting a repeat record

291
4
Jump to solution
04-28-2022 04:23 AM
KatieQuantrell
New Contributor II

Hi,

I've created a Survey123 form which contains three separate repeats (going into three separate feature layers on AGOL). A user has accidently added an unwanted repeat record to one of the repeat sections, and submitted their data. What is the best way to delete this single record from the feature layer on AGOL without also deleting all associated records submitted under that parent record? If I delete the record in Survey123 it deletes the entire response including all other repeat records. 

Any help would be much appreciated,

Thank you. 

0 Kudos
2 Solutions

Accepted Solutions
icf_Eric_Link
New Contributor III

One possible way would be to bring the feature service into ArcGIS Pro and open the table that contains the record you want to delete and delete it.  That should keep the remaining other records.  I would make sure to back up your data before editing.

View solution in original post

0 Kudos
DougBrowning
MVP Honored Contributor

Oh boy these are fun.  I have 200+ relationships so I have learned a bit.

First what type of relationship class is it?  You said it deletes so I would say managed. 123 using managed and I have asked them to add an option but no word.  https://community.esri.com/t5/arcgis-survey123-questions/option-to-set-relationship-classes-to-simpl...  I use "unmanaged" but all that means is instead of a delete it turns the keys to null.  Esri calls this simple and composite.  Good to read up on.

Next where are you deleting?  In my experience AGOL honors Composite but not Simple Relationship class rules.  See my post here https://community.esri.com/t5/arcgis-online-questions/agol-honors-composite-but-not-simple-relations...    Seems like a core bug to me but no response.  But if you hit the service in Pro it will.

I suggest use Pro and

As a general rule always delete the children then the parent.  Never delete the parent first.  As long as you roll up from bottom to top you should be ok.

Now what if you need to delete a parent but keep the children?  (this is a funky flow but it happens a lot with bad data and fixing)  The trick I found in a post (that I cannot find) works great.  On the parent records you want to delete, calculate field the keys to something like "delete".  Save.  Then delete the parents.  At this point arc will follow all the relationship classes down looking for any children that match the parents.  Since you made the key the word delete it will not find any children and thus do nothing.  Then you can replace the parents.  Note if you have a replica - you must calc the delete, replicate, delete, replicate again.

Now what if you used GlobalIDs for the relationship?  Well you are in a world of hurt - see my post here on not using GlobalIDs https://community.esri.com/t5/arcgis-collector-questions/related-tables-for-offline-data-collection/... 

But if you did what may work is to do the above trick in reverse.  Calculate the key of the children to a temp key like "temp".  Delete the parent and it will not find children.  Then replace the parent.  Calc the new parent GlobalID into the key of the children.

I hope all that makes sense it is both simple and complex.  Now when you have 2-4 levels deep it gets real fun.  Yours looks complicated but use these ideas.  Good luck

View solution in original post

0 Kudos
4 Replies
icf_Eric_Link
New Contributor III

One possible way would be to bring the feature service into ArcGIS Pro and open the table that contains the record you want to delete and delete it.  That should keep the remaining other records.  I would make sure to back up your data before editing.

0 Kudos
KatieQuantrell
New Contributor II

Thank you, this seems to of worked perfectly. 

0 Kudos
DougBrowning
MVP Honored Contributor

Oh boy these are fun.  I have 200+ relationships so I have learned a bit.

First what type of relationship class is it?  You said it deletes so I would say managed. 123 using managed and I have asked them to add an option but no word.  https://community.esri.com/t5/arcgis-survey123-questions/option-to-set-relationship-classes-to-simpl...  I use "unmanaged" but all that means is instead of a delete it turns the keys to null.  Esri calls this simple and composite.  Good to read up on.

Next where are you deleting?  In my experience AGOL honors Composite but not Simple Relationship class rules.  See my post here https://community.esri.com/t5/arcgis-online-questions/agol-honors-composite-but-not-simple-relations...    Seems like a core bug to me but no response.  But if you hit the service in Pro it will.

I suggest use Pro and

As a general rule always delete the children then the parent.  Never delete the parent first.  As long as you roll up from bottom to top you should be ok.

Now what if you need to delete a parent but keep the children?  (this is a funky flow but it happens a lot with bad data and fixing)  The trick I found in a post (that I cannot find) works great.  On the parent records you want to delete, calculate field the keys to something like "delete".  Save.  Then delete the parents.  At this point arc will follow all the relationship classes down looking for any children that match the parents.  Since you made the key the word delete it will not find any children and thus do nothing.  Then you can replace the parents.  Note if you have a replica - you must calc the delete, replicate, delete, replicate again.

Now what if you used GlobalIDs for the relationship?  Well you are in a world of hurt - see my post here on not using GlobalIDs https://community.esri.com/t5/arcgis-collector-questions/related-tables-for-offline-data-collection/... 

But if you did what may work is to do the above trick in reverse.  Calculate the key of the children to a temp key like "temp".  Delete the parent and it will not find children.  Then replace the parent.  Calc the new parent GlobalID into the key of the children.

I hope all that makes sense it is both simple and complex.  Now when you have 2-4 levels deep it gets real fun.  Yours looks complicated but use these ideas.  Good luck

0 Kudos
KatieQuantrell
New Contributor II

Thank you so much for all your advice. I've now managed to delete the child record in Arc Pro which seems to of worked fine. Really useful to know how you could also delete a parent whilst keeping the child records though so many thanks for explaining this too.