Governance Units: Why a Script Stops on Its Own
NetSuite caps how much work a single script execution may do. Understanding that cap explains errors that only appear once the data has grown.
NetSuite is shared by many accounts, so no script may consume resources without limit. Every API call costs a number of units, and every script type has an allowance. Once the allowance runs out, execution stops with SSS_USAGE_LIMIT_EXCEEDED.
This is why a script can pass every test and then fail months later: the logic did not change, the volume of data did.
Allowance per script type
| Script type | Unit allowance |
|---|---|
| Client Script | 1,000 |
| User Event Script | 1,000 |
| Suitelet | 1,000 |
| Workflow Action Script | 1,000 |
| RESTlet | 5,000 |
| Scheduled Script | 10,000 |
| Map/Reduce | 10,000 |
Cost of the operations you use most
| Operation | Units |
|---|---|
| search.lookupFields | 1 |
| Custom record — load | 2 |
| Custom record — save | 4 |
| Standard record — load | 5 |
| Standard record — save | 10 |
| Transaction — load | 10 |
| Transaction — save | 20 |
| search.run() / each() | 10 |
The full list lives in NetSuite Help under SuiteScript 2.x API Governance. What matters from the table above is the ratio: reading a couple of fields with lookupFields is far cheaper than loading a whole record, and saving a transaction is the most expensive thing you routinely do.
How to bring usage down
- Use search.lookupFields when you only need to read a few fields, not record.load.
- Use record.submitFields to change a couple of fields without loading the whole record.
- Do not call an API inside a loop when the result could be fetched once outside it.
- For large volumes, move to Map/Reduce — the allowance is counted per unit of work rather than once for everything.
- Watch the remaining allowance while running and stop cleanly before it is exhausted.
define(['N/runtime'], (runtime) => {
const script = runtime.getCurrentScript();
if (script.getRemainingUsage() < 100) {
// leave room to close the work tidily
log.audit('Governance', 'Units running low, stop the batch here.');
return;
}
});