Run a NetSuite SuiteScript 2.x map-reduce script to bulk-update work-order completion status across thousands of records while respecting per-phase governance limits
Define getInputData to return a SuiteQL query selecting open workOrder records; the phase receives 10,000 governance units and up to 60 minutes.
In the map phase, emit each work-order internalId as the key; keep map logic minimal — map invocations each receive 1,000 units, so load no extra records here.
In the reduce phase (5,000 units per invocation), load the work-order record with N/record.load, set status fields, and call record.save; wrap in try/catch and log failures to context.write.
In the summarize phase, iterate context.errors and send an email summary via N/email.send; check summary.seconds and summary.usage for audit logging.
Deploy the script via Setup > SuiteCloud > Script Deployments; set the queue and concurrency (max 5 reduce queues) appropriately for your account.
Test with a small data slice by adding a SuiteQL WHERE clause filter before promoting to full run.
Known gotchas
Exceeding getInputData governance (10,000 units) causes that phase to abort and jump directly to summarize, silently skipping all map and reduce processing — always test input query cost first.
Each reduce invocation handles all values for one key in sequence; if a single work order has many sub-keys the reduce call can still exhaust its 5,000-unit budget — keep keys granular.
Map and reduce phases reset governance counters per invocation, but getInputData and summarize do not reset — complex summarize logic can itself terminate the script.
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp