when you need to delete records, but before you ca...
# suitescript
n
when you need to delete records, but before you can delete them, you have to remove the dependent records sourced on the record you need to delete, what is the best way to script this to ensure everything is synchronously performed. I thought it would be straight forward with first record.load() then record.setValue() to remove the dependency then record.delete() but I am getting an error on the record.delete() due to dependent records. do I need to chain javascript promises or use async/await? does anyone know if you can use async/await in in suitescript 2.1?
r
Deleting records is usually a bad idea. If it's an entity, inactivate it. If it's a JE, reverse it. Etc. You probably can't just unset the dependent record on the source record. Try deleting the dependent records if that fits your use case. Also try unsetting the parent record on the dependent records. It's complaining because the dependent records are still considered dependent.