Does anyone know a way in SS 2 to check before del...
# suitescript
j
Does anyone know a way in SS 2 to check before deleting a record if it’s “in use” or has dependent records?
s
can you even delete a record if it has dependencies?
j
no. BUT. I’m trying to delete child records that have the parent as non-mandatory. And I can only delete on beforeSubmit (there’s no option on afterSubmit/Delete)
so I need to know beforehand if the delete of the parent record will fail
otherwise the child records get deleted THEN the parent remains because it fails on its delete
BTW parent is non-mandatory as it can be EITHER a Transaction OR a Submission sigh so I have two parent fields
s
Yea not sure about that. I also had trouble figuring out how to track record tendencies.
j
I’m increasingly thinking I just need to write a “clean up orphaned child records” scheduled script instead.
c
If you know the parent, you could search for children of that parent record ID, delete those then the parent and so forth. Its a little more work since you need to know what you're looking for but thats how i've done it in the past
if you just have no idea who the children are, thats gonna be a non-starter.
best you could do is delete the record in the UI and see the dependent records and do a couple of searches like the above for whatever pops up and delete those children. Alternatively, mark the relationship as allow to delete and set null, and write a script that comes in and picks up the null parent records and deletes them.