How to track deletes on Transaction Lines using Su...
# ask-stanley-ai
m
How to track deletes on Transaction Lines using SuiteQL
c
AI generated answer (using internal Slack threads):
****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ****** Tracking deletes on Transaction Lines using SuiteQL is not directly possible as NetSuite does not provide a built-in feature to track deleted transaction lines. However, there are a few workarounds that you can consider: 1. Client Scripting: You can use a client script with the "validateDelete" event. This event is triggered when a line item is removed. You can use this event to copy the line information to a custom field or a custom record when a line is removed. This way, you can capture more information like who deleted the line, when it was deleted, what item was deleted, quantity, custom fields, etc. You can even prompt the user for a reason for the deletion and store that information. Here is a pseudo code example:
Copy code
javascript
function validateDelete(context) {
    var currentRecord = context.currentRecord;
    var sublistName = context.sublistId;
    var line = context.line;
    // get the line item details
    var item = currentRecord.getSublistValue({
        sublistId: sublistName,
        fieldId: 'item',
        line: line
    });
    // store the item details in a custom field or a custom record
    // ...
    return true;
}
2. Saved Search: Another approach is to calculate the number of deleted lines in a transaction using a Saved Search. You can use the formula
MAX({line}) - MAX({linesequencenumber})
to calculate the number of deleted lines. However, this method may not be accurate as these fields do not necessarily increment by 1 on all transactions. 3. Third-party Solutions: There are also third-party solutions available that provide a "recycle bin" functionality to view deleted records in NetSuite. You can consider using these solutions if they meet your requirements. Remember, these are workarounds and may not cover all scenarios or meet all your requirements. You may need to customize these solutions based on your specific needs.
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.828085899
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.824600399
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.821261048
Please provide your feedback on this answer.