Six Tips for Building Robust Customizations with SuiteScripts

NetSuite provides a full set of features out of the box, but every organization has business policies and automation needs that may differ from standard functionality. Software developers using SuiteScript, NetSuite's scripting tool made up of JavaScript plus a set of functions and objects to interact with the NetSuite environment, can extend the functionality of standard and custom record types, including the development of entirely new user interfaces.. Here are some helpful tips for both the beginner and more advanced SuiteScript user:

  1. Extend your Business Processes. SuiteScript's vast array of script types can enhance interactivity in the browser, respond to users loading and saving records, coordinate batch processing, extend workflows created using SuiteFlow, build custom user interfaces, respond to integration requests, and more. Server-side SuiteScript gives you the full power of a JavaScript engine based on ECMAScript edition 5 language support. A few highlights of what you can do include validating user input, creating records, querying records, sending emails, and making outbound web services calls.
  2. Save Time. Take advantage of the power provided by the SuiteCloud IDE. You can use any JavaScript editor to build your SuiteScripts, but the SuiteCloud IDE provides plenty of productivity improvements. Code completion is available for the SuiteScript API, plus record type and field IDs. Add JavaScript doc comments to give smarts to user event scripts, causing code completion to provide results based on the current record. Get code completion for your custom fields and record types by synchronizing their definitions with the IDE. Upload and download files directly from the IDE.
  3. Support Maintainability. Save lots of headaches by incorporating simple naming conventions with script types having multiple event functions. Align script function names with their event. For example, name a script function afterSubmit in support of an After Submit event. The end result is that you can easily find the event functions when perusing a script file, without the need to refer to the script record.
  4. Optimize Performance. After Submit functions of user event scripts can slow down response time as end users save records because the functions are executed synchronously. Get around the issue by offloading intensive processing during After Submit to scheduled scripts via nlapiScheduleScript. Scheduled script execution becomes asynchronous relative to your user events. Another performance trick is to filter execution of your user event scripts to applicable execution context. Check out nlobjContext for more on this.
  5. Troubleshoot Problems Faster. Use nlapiLogExecution to write to a log that is accessible from script and script deployment records. Use server-side and client-side. Client-side scripts support browser alert and console.log statements, the same as with JavaScript running in any browser. Use the server-side script debugger for source code debugging on a majority of server script types. Download a recently released update to the SuiteCloud IDE, which contains an embedded server-side script debugger. Now you can debug your scripts directly from the IDE!
  6. Learn more. Anyone who works with SuiteScript should consider taking NetSuite's five-day training class: SuiteScript: Extend NetSuite with JavaScript. Contact Kerman Camacho, your NetSuite Education Advisor, for help with matching the right training to your needs and enrolling in classes.

- Bruce Tanenholtz, Program Manager of Technical Curriculum, NetSuite

comments powered by Disqus