Script

A script record allows you to deploy your entry point script. The SuiteScript Records Browser lists the script record for each script type separately (see table below).

For help working with script records in the UI, see Script Record Creation.

Each script record has a unique internal ID. The following table lists each internal id and provides links to the SuiteScript Records Browser for each type of script record. Refer to these records for all other internal IDs associated with each record.

Script Record

Internal ID

SuiteScript Records Browser Link

Bundle Installation Script

bundleinstallationscript

Bundle Installation Script

Client Script

clientscript

Client Script

Map/Reduce Script

mapreducescript

Map/Reduce Script

Massupdate Script

massupdatescript

Massupdate Script

Portlet

portlet

Portlet

Restlet

restlet

Restlet

Suitelet

suitelet

Suitelet

User Event Script

usereventscript

User Event Script

Workflow Action Script

workflowactionscript

Workflow Action Script

Note:

For information about using the SuiteScript Records Browser, see Working with the SuiteScript Records Browser in the NetSuite Help Center.

For information about scripting with records in SuiteScript, see the following help topics:

Supported Script Types

Script records are scriptable in server SuiteScript only.

All three user events are supported: beforeLoad, beforeSubmit, and afterSubmit.

Supported Functions

Each script record is partially scriptable — it can be updated and searched. It cannot be created, copied, or deleted.

Usage Notes

You can load, update and save, and search script records with all server script types. Script records are not exposed to client scripts.

The following objects are not scriptable on any script record:

The following objects are read-only (editing is not supported):

To access script records within a script, the script owner must belong to a role assigned with SuiteScript permissions.

Important:

Scripts can only access script records when the records are part of the same bundle.

Scripts that are not part of a bundle cannot access script records that are part of a bundle.

For the id parameter in record.load(options), search.load(options), or search.create(options) methods, you must use the script record’s internal ID (for example, 191); the script record’s ID (for example, customscript_csalert) is not supported. You can find a script record’s internal ID at Customization > Scripting > Scripts. If you have the Show Internal IDs preference enabled at Home > Set Preferences, internal IDs are listed in the Internal ID column.

The Scripts page with the Internal ID column highlighted.

For record and search methods that require the type parameter, use one of the following record.Type or search.Type values:

Code Samples

The following samples show how to load and read a script record, how to create a script record, and how to search a script record.

            // Read a SUITELET script record
var rec = record.load ({
    type: record.Type.SUITELET,
    id: 605
}); 
var a = rec.getValue({
    fieldId: 'scriptfile'
});
var count = rec.getLineCount ({
    sublistId: 'parameters'
}); 
var pLabel = rec.getSublistValue ({
    sublistId: 'parameters',
    fieldId: 'label',
    line: 1
});
var pId = rec.getSublistValue ({
    sublistId: 'parameters',
    fieldId: 'internalid',
    line: 1
});
var pType = rec.getSublistValue ({
    sublistId: 'parameters',
    fieldId: 'fieldtype',
    line: 1
}); 
var pRecordType = rec.getSublistValue ({
    sublistId: 'parameters',
    fieldId: 'selectrecordtype',
    line: 1
}); 

          
            // Edit a user event script record
var rec = record.load ({
    type: record.Type.USEREVENT_SCRIPT,
    id: 302
});
rec.setValue ({
    fieldId: 'name',
    value: 'userevent_001'
});
rec.setValue ({
    fieldId: 'scriptfile',
    value: '227'
});
rec.setValue ({
    fieldId: 'notifyadmins',
    value: 'T'
});
rec.setValue ({
    fieldId: 'aftersubmitfunction',
    value: 'afterSubmitFunction'
});
rec.save(); 

          
            // Search a script record
var searchFilters = search.createFilter ({
    name: 'defaultfunction',
    operator: search.Operator.IS,
    values: 'myfunctionname'
});
var searchColumns = search.createColumn ({
    name: 'name'
});
var mySearch = search.create ({
    type: search.Type.SUITELET,
    filters: searchFilters,
    columns: searchColumns
});
var mySearchResults = mySearch.run(); 

          

Related Topics

SuiteScript 2.x Script Types
Working with the SuiteScript Records Browser
SuiteScript Supported Records
Customization

General Notices