SuiteScript FAQ

This FAQ covers several topics:

For FAQ information related to SOAP web services, see SOAP Web Services Frequently Asked Questions (FAQ).

General

How often is the SuiteScript API documentation updated?

The SuiteScript API documentation is frequently updated and pushed to the NetSuite Help Center.

For the most current API documentation, see SuiteScript 2.x API Reference.

Which records are supported in SuiteScript?

All information regarding SuiteScript-supported records, fields, tabs, sublists, search filters, and search columns is located in the NetSuite Help Center.

See SuiteScript Supported Records for information about supported records.

See the SuiteScript Records Browser for details related to SuiteScript-supported records.

Which sublists are supported in SuiteScript?

All information regarding SuiteScript-supported records, fields, tabs, sublists, search filters, and search columns is located in the SuiteScript Records Browser.

See the SuiteScript Records Browser for details related to SuiteScript-supported sublists and their internal IDs.

What is the difference between SuiteScript 1.0 and SuiteScript 2.x?

SuiteScript 1.0 uses global functions while SuiteScript 2.x is modular. The functions in SuiteScript 1.0 are synchronous on client, while SuiteScript 2.x can use asynchronous processing. SuiteScript 2.x offers more APIs. New functionality is being added to SuiteScript 2.x only.

See the SuiteScript 1.0 to SuiteScript 2.x API Map for more details on the differences.

A new version of SuiteScript, SuiteScript 2.1, is also available. This version is the latest minor version of SuiteScript. It extends SuiteScript 2.x by supporting additional ECMAScript language features and syntax. For more information, see SuiteScript 2.1.

What version of SuiteScript should I use?

Use SuiteScript 2.x for new scripts that you develop, and consider converting your SuiteScript 1.0 scripts to SuiteScript 2.0 or SuiteScript 2.1.

SuiteScript 1.0 is no longer being updated (no new feature development or enhancement work is being done). SuiteScript 1.0 scripts continue to be supported, but you should use SuiteScript 2.x for any new or substantially revised scripts to take advantage of new features, APIs, and functionality enhancements.

A new version of SuiteScript, SuiteScript 2.1, is also available. This version is the latest minor version of SuiteScript. It extends SuiteScript 2.x by supporting additional ECMAScript language features and syntax. For more information, see SuiteScript 2.1.

Does SuiteScript support the use of multiple library files?

Yes. Multiple library files can be loaded onto the Script record page. The Script record page is where you define the SuiteScript .js file you want to execute, as well as any associated library files that may be required when the SuiteScript code executes.

Also be aware that the system reads your library files in the order they appear on the Library Script File tab on the Script record page. For example, if your first library file references the second library file, an error will be thrown, since the first library file is loaded before the second.

If you do not know how to create a Script record, or where on the Script record you must load your library files, go to the topic Creating a Script Record in the NetSuite Help Center.

What is the difference between Standard and Dynamic mode?

When a SuiteScript 2.x script creates, copies, loads, or transforms a record in standard mode, the record’s body fields and sublist line items are not sourced, calculated, and validated until the record is saved. In dynamic mode, the record’s body fields and sublist line items are sourced, calculated, and validated in real-time.

See SuiteScript 2.x Standard and Dynamic Modes for more details.

What are the best practices when using Standard and Dynamic mode?

Standard mode is faster in many scenarios. It is better to use it if only read operation is needed.

Dynamic mode may be needed when doing write operations of fields on which other field depend.

See SuiteScript 2.x Standard and Dynamic Modes for more details.

How do I use require Configuration?

If you set up a valid @NAmdConfig JSDoc tag, SuiteScript implements the require configuration settings before loading dependencies.

See require Configuration for more details.

What is SuiteScript governance?

Governance serves like a sanity check of a script. If there is a bug in a script like unwanted infinite loop, governance prevents the script to run indefinitely.

To optimize application performance, NetSuite has implemented a SuiteScript governance model based on usage units. If the number of allowable units is exceeded, the script is terminated.

See SuiteScript Governance and Limits for more details.

What is SuiteCloud Processors?

SuiteCloud Processors is the current system used to process scheduled scripts and map/reduce scripts. Before SuiteCloud Processors was introduced, scheduled scripts and map/reduce scripts were exclusively processed by scheduling queues.

See SuiteCloud Processors for more details.

Which is better to use: Scheduled script or Map Reduce script?

Scheduled script is better for simple tasks which cannot run in parallel. Map/Reduce script is better suited for processing massive data in parallel, since it is faster then Scheduled script.

See SuiteScript 2.x Scheduled Script Type and SuiteScript 2.x Map/Reduce Script Type for more details.

What version of ECMAScript does SuiteScript support?

SuiteScript 1.0 and SuiteScript 2.0 support ECMAScript 5.1.

SuiteScript 2.1 supports ECMAScript 6. This version is the latest minor version of SuiteScript. It extends SuiteScript 2.x by supporting additional ECMAScript language features and syntax. For more information, see SuiteScript 2.1.

Can a User Event script be used to trigger another User Event script?

Nested user event script execution is not supported.

See SuiteScript 2.x User Event Script Type for more details.

SDF and SuiteApps

What is SDF and how does it help me develop with SuiteApps?

SuiteCloud Development Framework (SDF) is a development framework that you can use to create SuiteApps from an integrated development environment (IDE) on your local computer. Using SDF lets you manage client and server scripts as part of file-based customization projects. You can also use SDF with the SuiteCloud Software Developer Kit (SDK) as the best solution for creating a script as a part of an overall NetSuite customized solution packaged with other factors, such as custom records, custom forms, other scripts, or more. For more information about SDF, see SuiteCloud Development Framework,

Is there a special script type for installing SDF projects?

Yes. The SDF installation script type is used to perform tasks during development of a SuiteApp from SDF to your target account. You can use the SDF installation script type to perform setup, configuration, and data management tasks that otherwise would have to be completed by account administrators. For more information about the SDF installation script type, see SuiteScript 2.x SDF Installation Script Type.

Does SuiteScript have a module that I can use to see information about my SuiteApp?

Yes. You can use the N/suiteAppInfo module to access information related to your SuiteApp including whether a specific SuiteApp is installed and a lsit of all SDF SuiteApps that are installed, along with the ID for the SDF SuiteApp that contains a specific script (for multiple scripts specified). For more information about the N/suiteappInfo module, see N/suiteAppInfo Module.

Code

How can I control the execution order of scripts deployed on a record?

After logging in NetSuite, go to Customization > Scripting > Scripted Records. Select your record type. You can drag the scripts up or down. This step controls the order of their execution.

How many client and user event scripts can I deploy in a record?

There is no limit on the number of client or user event scripts that can be deployed. However, performance issues may occur if you have a lot of scripts deployed on a single record.

How do I add a button in a User Event script that redirects to a Suitelet in SuiteScript 2.x?

In the beforeLoad callback, one is supplied with a form object on which any button can be added. That button can execute an arbitrary function. The function must use document.location = <url of a suitelet> for redirect.

See SuiteScript 2.x User Event Script Type or SuiteScript 2.x Suitelet Script Type for more details.

Can I write to a script parameter field I have created in my code?

Although you can read the value of a script parameter field, you cannot programmatically set the value. The only time you can specify a value outside of the UI is when you call task.create(options).

                var myTask = task.create({task.TaskType.SCHEDULED_SCRIPT});
myTask.scriptId = <id of your script>;
myTask.deploymentId = <id of your script deployment>;
myTask.params = <your params>;
myTask.submit(); 

              

See Creating Script Parameters Overview for more information about creating and working with script parameters.

How do I mass delete records using SuiteScript?

Currently, there is no SuiteScript function that enables you to mass delete records in one batch process. In SuiteScript, you have to delete each record individually using record.delete(options).

Which certificate authorities (CAs) does NetSuite support?

NetSuite supports the same list of trusted third-party certificate authorities (CAs) as Mozilla Included CA Certificate List.

The target endpoint, domain, or server must use one of these trusted third–party CAs, or the connection cannot be established. Oracle NetSuite requires that the endpoints that you are connecting to from NetSuite provide a full certification chain, including intermediate certificates.

For a list of certificate authorities, see https://wiki.mozilla.org/CA/Included_Certificates.

Can I throw an alert in a Suitelet?

You can attach a client script by using the N/ui/message Module.

                /**
 * @NApiVersion 2.1
 * @NScriptType Suitelet
 */
define(['N/ui/serverWidget', 'N/ui/message'], function(serverWidget, message){
    function onRequest(context){
        let form = serverWidget.createForm('Alert Form');
        let msg = message.create({
            type:message.Type.WARNING,
            title:"Alert",
            message: "Something occurred",
            duration: 5000
        });
        form.addPageInitMessage(msg);
        context.response.writePage(form);
    }

    return{
        onRequest: onRequest
    }
}); 

              

N/ui/message Module and N/ui/dialog Module are executable in client scripts only.

Is there a change in creating subrecords in SuiteScript 2.x?

Yes. SuiteScript 2.x includes changes in how your script subrecords.

See Subrecord Scripting in SuiteScript 2.x Compared With 1.0 for more details.

How do I optimize SuiteScript performance?

There are several guidelines that you can follow to optimize SuiteScript performance.

See Optimizing SuiteScript Performance for more details.

Should I use record-level or form-level scripts?

There are different forms used for different users. They should be used when one needs to execute different scripts for different users. Record-level script is always used regardless of the user. Based on that, one can decide which type of script should be used.

See Record-Level and Form-Level Script Deployments for more details.

Where can I find the records and their scripts?

The Scripted Records page lists all the records that have user event or global client script that is associated with a record.

See The Scripted Records Page for more details.

What is the difference between Map Reduce and Scheduled Script?

The map/reduce script type is designed for scripts that need to handle large amounts of data. It is best suited for situations where the data can be divided into small, independent parts.

Scheduled scripts are server scripts that are executed (processed) with SuiteCloud Processors. It is run sequentially unlike Map/Reduce, where its stages are executed in parallel.

See SuiteScript 2.x Script Types for more details.

Is DOM supported in SuiteScript?

SuiteScript does not support direct access to the NetSuite UI through the Document Object Model (DOM). The NetSuite UI should only be accessed using SuiteScript APIs.

What are the required SuiteScript 2.x JSDoc Tags?

For entry point scripts, NApiVersion and NScriptType JSDoc tags are required. For more information about JSDoc tags, see the help topic: SuiteScript 2.x JSDoc Validation.

What are the stages required in a Map Reduce script?

At least getInput and one of map/reduce stages are required.

What does the script context seen in System Notes represent regarding the action on the record?

It is the context from which the operation was triggered that changed the field. So if you consider stack of operations, it is the second most nested scope.

For example, if in the UI, the pageInit callback is used on a record to call nlapiRequestURL to trigger a Suitelet. This calls another nlapiRequestURL to trigger a RESTlet, which loads a record that triggers a user event that finally manipulates the field, then the context is restlet. The stack will be UI/Client/Suitelet/Restlet/UserEvent. RESTlet is the second most nested scope.

How do you reference Custom Modules in SuiteScript 2.x?

You can add them by path to the dependencies of your define callback.

What is the difference between scriptContext.newRecord and scriptContext.oldRecord in SuiteScript 2.x?

scriptContext.oldRecord holds a copy of a record before any manipulation is completed on it. It is not available while creating new record.

scriptContext.newRecord contains the record which can be modified in the beforeSubmit callback to save the record differently than it was set in UI. For example, you can override a memo before the record is saved.

Additional tools to work with along with SuiteScript

What other tools are available to help me write my SuiteScript scripts?

Several tools are available, including SDF and SDK and the Records Catalog and the Records Browser. For more information about SDF and SDK, see SuiteCloud Development Framework. For more information about the Records Catalog and the Records Browser, see The Records Catalog and SuiteScript Records Browser. For more information about additional SuiteCloud tools, see SuiteCloud Reference Tools.

Errors

You can find SuiteScript error descriptions in SuiteAnswers. Type the error in the search box and click Search.

How does “Record Has Been Changed” error get triggered in SuiteScript execution?

This error can happen when another user or script has manipulated the record in parallel.

See the SuiteAnswers article Prevent losing data because of the error "Record has been changed" for more details.

What is the “You do not have privileges to view this page” error message on the script deployments page?

End users accessing Suitelets will receive this error if any of the Select All box on the Audience tab on the Script Deployment page was not selected. This is true even for users who are accessing the Suitelet externally (for example, users who are accessing a Suitelet using the “external” Available Without Login URL for the Suitelet.)

See Errors Related to the Available Without Login URL for more details.

What is the “You are not allowed to navigate directly to this page” error message when accessing Suitelet?

End users accessing Suitelets through the Available Without Log external URL will receive this error if the Status field on the Suitelet's Script Deployment page has not been set to Released.

See Errors Related to the Available Without Login URL for more details.

Why am I getting an “SSS_USAGE_LIMIT_EXCEEDED ID” error?

The script exceeded its usage point limit for a single execution. If this error occurs twice, the script execution will stop.

For more information about usage limits, see the help topic SuiteScript Governance and Limits

It is best that you monitor your script usage because there are limits. For more information, see Monitoring Script Usage.

Why am I getting an “SSS_REQUEST_LIMIT_EXCEEDED” error?

This error is thrown if a single execution of a server script or application has taken longer than its limit.

For more information about usage limits, see the help topic SuiteScript Governance and Limits

Why am I getting “SSS_INVALID_SUBLIST_OPERATION” error?

A line item field value is being set on a non-existing line. The sublist doesn't exist or is not editable.

See the SuiteAnswers article SuiteScript Error SSS_INVALID_SUBLIST_OPERATION for more details.

Logs

How long will the script execution logs be available on my account?

There are two locations to find script execution logs:

  • Execution Log tab on Script and Script Deployment records — The capacity for script execution logs on the Execution Log tab is shared by customers on the same database. For protection against excessive logging, script execution logs are governed by a total storage limit on each instance of the NetSuite database. On each NetSuite server, if the database table that stores logs reaches this limit, all logs (across all customers on that server) are purged. This means that you may have logs past 30 days if the volume is low, but you may have logs of less than a week if the log volume is extremely large. For this reason, you should store information from logs that you need to save using custom records.

  • Script Execution Log page — The execution logs at Customization > Scripting > Script Execution Logs store logs for up to 30 days, regardless of volume. However, there is a limit of 10,000 results that can be displayed on this page. If you have more than 10,000 logs in 30 days, you can view these logs by filtering the Script Execution Log page. Click the Filters section at the top of the page to expand the filters and limit to date range, script, or log level to access the logs you need. Note that a full search or Customize View option is not available for this page.

Can I use execution logs in a client script?

Yes. For SuiteScript 1.0, use nlapiLogExecution (see SuiteScript 1.0 Documentation). For SuiteScript 2.x, use N/log Module.

Related Topics

SuiteScript 1.0 Documentation
Working with the SuiteScript Records Browser
Setting Runtime Options

General Notices