I have a table called events and a table called usereventyns which has a column linked to a single event.
If I delete an event row and then examine the usereventyns in the table editor the rows linked to the now deleted event show ‘Unknown Row’ in the link column. How can I find these ‘orphaned’ usereventyns in code? Essentially, if I delete an event I want to ensure that any linked rows in usereventyns are also deleted.
I tried something along the lines of this
Code Sample:
yns=app_tables.usereventyns.search()
for yn in yns:
yneventlink=yn['eventlink']
if yneventlink = 'Unknown Row' ....
but it obviously wouldn't allow a string as a link
You can clean up those rows when you delete the event, so that you don’t have links to unknown rows to worry about.
1 Like
Thanks, that was my plan but I wanted to be able to find and delete orphans just in case something went wrong during an event deletion.
You can try iterating through all the links in a multiple link field, adding each good link to a new set of links, doing the add inside a try/except, so that unknown links don’t get added. It’d take some experimentation to get it right, but catching the exception that happens when you try to access a column through the orphaned link is the only way to know that it’s an orphaned link.
1 Like
Yup, that works. Thanks again.