**User:** how to work After Destroy hook

**Assistant:** The "After Destroy" hook allows you to perform actions after a record is deleted from a table. Think of it as a way to trigger additional processes or updates in other parts of your system based on a record deletion. Here's how it works in the context of the provided information:

1. Timing: The "After Destroy" hook executes before the standard system deletion process finishes, but you can control this.

2. Access to Data: You have access to all the field values of the deleted record within the hook. This is useful if you need to use that information for subsequent actions.

3. table.super(): If you need the standard deletion process to complete before your custom actions in the hook, use the table.super() function within your hook's code. This ensures the standard deletion happens first, then your code executes.

4. Example: The provided code snippet demonstrates logging information about a deleted sales order. After the record is deleted, the txcomdll0001.log.deleted.sales.order function is called with relevant data from the deleted order. Notice the table.super() call is made first, ensuring the standard deletion completes before logging.

5. Implementation: You'll implement your "After Destroy" hook logic within the after.destroy.object() function in the appropriate script for your table (e.g., tdsls400 for the sales order table). In short: Use the after.destroy.object() function to define actions to occur after a record is deleted. Use table.super() within this function if the standard deletion process needs to complete first. You have access to the deleted record's field values inside the function.

After Destroy hook