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 |
|
|
Client Script |
|
|
Map/Reduce Script |
|
|
Massupdate Script |
|
|
Portlet |
|
|
Restlet |
|
|
Suitelet |
|
|
User Event Script |
|
|
Workflow Action Script |
|
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 Change ID button (in Edit view of UI)
-
The Unhandled Errors tab
-
The History tab
-
The System Notes tab
-
The Execution Log tab
-
The Libraries tab
The following objects are read-only (editing is not supported):
-
The Type field
-
The Parameters tab
To access script records within a script, the script owner must belong to a role assigned with SuiteScript permissions.
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.](img/SuiteCloudCustomizationScriptingWebServices/SuiteScript/SuiteScriptDeveloper/SuiteScriptRecordsGuide/ScriptRecord_InternalID.png)
For record and search methods that require the type parameter, use one of the following record.Type or search.Type values:
-
BUNDLE_INSTALLATION_SCRIPT
-
CLIENT_SCRIPT
-
MAP_REDUCE_SCRIPT
-
MASSUPDATE_SCRIPT
-
PORTLET
-
RESTLET
-
SUITELET
-
USEREVENT_SCRIPT
-
WORKFLOW_ACTION_SCRIPT
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();