SuiteScript
This domain tests SuiteScript 2.x: which script type fits a requirement, which entry point fires, and how governance shapes the design.
Script types and entry points
- Client scripts run in the browser: pageInit, fieldChanged, validateField, postSourcing, saveRecord, sublistChanged.
- User Event scripts run server-side: beforeLoad, beforeSubmit, afterSubmit.
- Scheduled, Map/Reduce, RESTlet, Suitelet, Portlet, Workflow Action, and Mass Update scripts cover batch, API, UI, and workflow needs.
- Modules include N/record, N/search, N/runtime, N/https, N/ui/serverWidget, N/format, N/cache, and N/query.
Governance and API behavior
- Each execution has a usage-unit budget; runtime.getCurrentScript().getRemainingUsage() lets a script yield before it fails.
- Map/Reduce splits work into getInputData, map, reduce, and summarize stages, which suits large volumes better than one scheduled run.
- record.submitFields performs a lightweight update and does not trigger User Event scripts or workflows.
- record.load with isDynamic avoids loading the entire record; search results are paged and must be iterated.
Worked example
A scheduled script processing 5,000 invoices hits the usage limit. Convert it to Map/Reduce: getInputData returns the invoice IDs, map processes each within its own governance budget, reduce summarizes results. Reasoning: the work is unchanged, but governance resets across stages and map invocations, so the job completes.
Traps that cost marks
- Writing SuiteScript 1.0 nlapi calls inside 2.x code.
- Expecting submitFields to fire User Event logic or workflows.
- Forgetting to release the deployment, so the script never runs.
- Assuming client scripts can do everything server scripts can.