How to safely delete multiple Work Order records along with records from related tables
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi,
I need to clean up multiple records from the Work Order table along with their associated records from approximately 10 related tables.
I’m looking for the safest and recommended approach to perform this cleanup while maintaining data integrity.
Specifically:
- How can I bulk delete the required Work Order records?
- How should I identify and delete records associated with those Work Orders from the related tables?
- Is there a recommended method, such as a Fix Script, Background Script, cascade delete, or Delete Multiple, for this type of cleanup?
- What precautions should be taken regarding reference relationships, business rules, audit/history records, and other dependencies?
- What is the recommended order of deletion when multiple related tables are involved?
Any best practices or sample approaches for safely performing this cleanup would be helpful.
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
ahoy @vijani,
I'd recommend fix script over background script, both have recovery record to revert data back if needed but fix script can be saved, background script is lost and must be searched in the execution history (available for limited time).
Also, I would recommend to use setWorkflow(false) method to avoid triggering more business rules, workflows and/or notifications... Perhaps try it first in non-production env on a smaller sample of data before deleting it, then investigate the results to understand to what has happened "behind the scenes".
For the related records, check Task table or any m2m table to see the relationship between WOs and the other tables.
Last but not least, depending on the amount of records, you might want to schedule this after business hours (unless your client operates around the clock)