Published on April 7, 2025.
To cancel a transaction via SuiteScript, you cannot simply update the record's status value.
Instead, you have to close each line.
Below is a snippet of SuiteScript that shows how to do this.
recordObj = record.load( { type: record.Type.SALES_ORDER, id: transactionID, isDynamic : true } ); var lineCount = recordObj.getLineCount( { sublistId: 'item' } ); for ( var i = 0; i <= ( lineCount - 1 ); i++ ) { var sublistLine = recordObj.selectLine( { sublistId: 'item', line: i } ); recordObj.setCurrentSublistValue( { sublistId: 'item', fieldId: 'isclosed', value: true } ); recordObj.commitLine( { sublistId: 'item' } ); } recordObj.save( { enableSourcing: true, ignoreMandatoryFields: true } );
Note that this doesn't actually cancel the transaction. Instead, it closes it. By closing the lines, you're indicating that you do not intend to fulfill them. And by closing all of the lines, you're effectively closing the entire order.
The difference between a cancelled and a closed transaction is that you can re-open a closed transaction (by un-checking the "Closed" value for each line).
Hello, I’m Tim Dietrich. I design and build custom software for businesses running on NetSuite — from mobile apps and Web portals to Web APIs and integrations.
I’ve created several widely used open-source solutions for the NetSuite community, including the SuiteQL Query Tool and SuiteAPI, which help developers and businesses get more out of their systems.
I’m also the founder of SuiteStep, a NetSuite development studio focused on pushing the boundaries of what’s possible on the platform. Through SuiteStep, I deliver custom software and AI-driven solutions that make NetSuite more powerful, accessible, and future-ready.
Copyright © 2025 Tim Dietrich.