- Always thoroughly test your code before using it on your live NetSuite data.
- Type all record, field, sublist, tab, and subtab IDs in lowercase in your SuiteScript code.
- Prefix all custom script IDs and deployment IDs with an underscore (_).
- Do not hard code any passwords in scripts. The password and password2 fields are supported for scripting.
- If the same code is used across multiple forms, ensure that you test any changes in the code for each form that the code is associated with.
- Include proper error handling sequences in your script wherever data may be inconsistent, not available, or invalid for certain functions. For example, if your script requires a field value to validate another, ensure that the field value is available.
- Organize your code into reusable chunks. Many functions can be used in a variety of forms. Any reusable functions should be stored in a common library file and then called into specific event functions for the required forms as needed.
- Place all custom code and markup, including third party libraries, in your own namespace.
- Important: Custom code must not be used to access the NetSuite DOM. Developers must use SuiteScript APIs to access NetSuite UI components.
- Use the built in Library functions whenever possible for reading/writing Date/Currency fields and for querying XML documents
- During script development, break your scripts into components, load them individually, and then test each one — inactivating all but the one you are testing when multiple components are tied to a single user event.
- When working with script type events, your function name should correspond with the event. For example, a pageInit event can be named PageInit or formAPageInit.
- Since name values can change, ensure that you use static ID values in your API calls where applicable.
- Although you can use any desired naming conventions for functions within your code, you should use custom namespaces or unique prefixes for all your function names.
- Thoroughly comment on your code. This practice helps with debugging and development and assists NetSuite Customer Support in locating problems if necessary.
- You must use the runtime.getCurrentScript() function in the runtime module to reference script parameters. For example, use the following code to obtain the value of a script parameter named custscript_case_field:

- Make sure that your script does not take a long time to execute. A script may execute for a long time if any or all the following occur:
- The script performs a large number of record operations without going over the usage limit.
- The script causes many user event scripts or workflows to execute.
- The script performs database searches or updates that collectively take a long time to finish.
- Each server script type or application has a time limit for execution. This limit is not fixed and depends on the script type or application. If a single execution of a server script or application takes longer than the time limit for that script type or application, a SSS_TIME_LIMIT_EXCEEDED error is thrown. This error can also be thrown from a script executed by another (for example, a user event script executed by a scheduled script).