RE: Deleted Record and Transaction Numbering Audit Log

Has anyone managed to link the Deleted Record and Transaction Numbering Audit Log tables in SuiteQL so that you can return the reasons for deleted records?

This will return deleted Invoices from last year:


SELECT

DeletedRecord.DeletedDate,

DeletedRecord.Type,

DeletedRecord.RecordID,

DeletedRecord.DeletedBy,

DeletedRecord.Context

FROM

DeletedRecord

WHERE

( DeletedRecord.DeletedDate >= TO_DATE ( '2024-01-01', 'YYYY-MM-DD' ) )

AND ( DeletedRecord.DeletedDate <= TO_DATE ( '2024-12-31', 'YYYY-MM-DD' ) )

AND ( DeletedRecord.Type = 'INVOICE')

And this will return the Reasons:


SELECT

TransactionNumberingAuditLog.dateDeleted,

TransactionNumberingAuditLog.deletedBy,

BUILTIN.DF( TransactionNumberingAuditLog.transactionDeletionReason ) AS Reason,

TransactionNumberingAuditLog.deletionReasonMemo,

TransactionNumberingAuditLog.deletionReasonOrigin,

TransactionNumberingAuditLog.transaction,

TransactionNumberingAuditLog.tranNumber,

TransactionNumberingAuditLog.tranType

FROM

TransactionNumberingAuditLog

WHERE

( TransactionNumberingAuditLog.dateDeleted >= TO_DATE ( '2024-01-01', 'YYYY-MM-DD' ) )

AND ( TransactionNumberingAuditLog.dateDeleted <= TO_DATE ( '2024-12-31', 'YYYY-MM-DD' ) )

AND ( TransactionNumberingAuditLog.tranType = 'CustInvc')

Both return the correct results:

RE: Deleted Record and Transaction Numbering Audit Log

RE: Deleted Record and Transaction Numbering Audit Log

But the transaction ID field is NULL in the Audit log. I have the TRANNUMBER field, but I don’t have that in the Deleted Record table.

Is there any way to do a SQL JOIN on the date created fields? I know there is a risk I might not get the correct link, but for this use case (deleted Invoices for our annual audit) I think that risk is very low.

I did try a couple of permutations of date linking, but failed to get a working script. I’m vaguely familiar with SQL joins, but it’s been a while since I used them, so it may just be my formatting is wrong.

If any can suggest a script that will allow me to link these two tables, I would be very grateful.

Add Comment
2 Answers

Great effort with those SuiteQL queries for deleted invoices and audit logs! Tricky spot with the missing transaction ID link. Since TRANNUMBER isn’t in DeletedRecord, you can try a JOIN on DeletedRecord.DeletedDate and TransactionNumberingAuditLog.dateDeleted, filtering both to match your 2024 range and tranType ‘CustInvc’ with DeletedRecord.Type ‘INVOICE’.

At RILE CPQ, we’ve tackled similar data linkage challenges to support audits.

Here’s a shot: SELECT DeletedRecord.DeletedDate, DeletedRecord.Type, DeletedRecord.RecordID, DeletedRecord.DeletedBy, BUILTIN.DF(TransactionNumberingAuditLog.transactionDeletionReason) AS Reason FROM DeletedRecord JOIN TransactionNumberingAuditLog ON DeletedRecord.DeletedDate = TransactionNumberingAuditLog.dateDeleted WHERE (DeletedRecord.DeletedDate >= TO_DATE(‘2024-01-01’, ‘YYYY-MM-DD’)) AND (DeletedRecord.DeletedDate <= TO_DATE(‘2024-12-31’, ‘YYYY-MM-DD’)) AND (DeletedRecord.Type = ‘INVOICE’) AND (TransactionNumberingAuditLog.tranType = ‘CustInvc’).

Test it and let me know how it lands! 💜

Rookie Answered on July 21, 2025.

Thanks Christian – that example returned nothing, but when I formatted the 2 date fields then I got some results (but not what I need).

After a little experimenting, I’ve found that the two tables are stored in different timezones (why does NetSuite do that?!)

2024-02-01 02:02:18 INVOICE 6044867
2024-02-01 10:02:18 2249 Duplicate Transaction

You can match just on the date:

JOIN TransactionNumberingAuditLog ON TO_CHAR(DeletedRecord.DeletedDate, ‘YYYY-MM-DD’) = TO_CHAR(TransactionNumberingAuditLog.dateDeleted, ‘YYYY-MM-DD’)

But I had 1 day with 2 invoices deleted on the same day, and that returns 4 results. I also had 1 missing – I’m guessing because they were recorded on different days (due to the 8 hour time difference between the tables).

I’m guessing I should be able to use something to convert both tables to matching times? SuiteQL doesn’t seem to allow ‘AT TIME ZONE’  – is there an alternative?

on July 21, 2025.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.