Load the transaction module to void transactions.
When you void a transaction, the total and all the line items for the transaction are set to zero. The transaction is not removed from the system. NetSuite supports two types of voids: direct voids and voids by reversing journal.
The type of void performed with your script depends on the targeted account’s preference settings:
- If the Using Reversing Journals preference is disabled, a direct void is performed.
- If the Using Reversing Journals preference is enabled, a void by reversing journal is performed.
transaction.void(options)
In the code sample below, a sales order is voided. You must disable the Void Transactions Using Reversing Journals feature in your NetSuite account by navigating to Setup > Accounting > Preferences > Accounting Preferences to avoid an error being thrown. To see which transactions support this feature, refer to the chart in transaction.Type.
var voidSalesOrderId = transaction.void({
type: transaction.Type.SALES_ORDER, //disable Void Transactions Using Reversing Journals in Account Pref
id: salesOrderId
});