record.create(options)

Note:

The content in this help topic pertains to SuiteScript 2.0.

Method Description

Creates a new record.

When you create records of certain types, you can use the defaultValues parameter to provide default values for fields in the new record. For some record types, some default values are required. For example, when you create a script deployment record, you must provide the internal ID of an existing script in your account (to associate with the script deployment record):

                    var scriptDeployment = record.create({
    type: record.Type.SCRIPT_DEPLOYMENT,
    defaultValues: {
        script: 205       // Internal id of existing script record
    }
}); 

                  

Make sure that you check for supported default values as you create records. For a list of available record default values, see N/record Default Values.

Note:

For the promise version of this method, see record.create.promise(options). Note that promises are only supported in client scripts.

Returns

record.Record

Supported Script Types

Client and server scripts

For more information, see SuiteScript 2.x Script Types.

Governance

Transaction records: 10 units

Custom records: 2 units

All other records: 5 units

Module

N/record Module

Since

2015.2

Parameters
Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

Since

options.type

string

required

The record type.

This value determines the Record.type property of the record that is created. This property is read-only on an existing record.

Use the following guidelines:

  • When creating an instance of a standard NetSuite record type, set this value by using the record.Type enum.

  • When creating an instance of a custom record type, set this value by using the custom record type’s string ID. For help finding this ID, see Custom Record.

2015.2

options.isDynamic

boolean

optional

Determines whether the new record is created in dynamic mode.

  • If set to true, the new record is created in dynamic mode.

  • If set to false, the new record is created in standard mode.

By default, this value is false.

Note:

For additional information about standard and dynamic mode, see record.Record and SuiteScript 2.x Standard and Dynamic Modes.

2015.2

options.defaultValues

Object

optional

Name-value pairs containing default values of fields in the new record.

By default, this value is null.

For a list of available record default values, see N/record Default Values in the NetSuite Help Center.

2015.2

Errors

Error Code

Thrown If

SSS_MISSING_REQD_ARGUMENT

A required argument is missing or undefined.

Syntax

Important:

The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/record Module Script Samples.

          // Add additional code
...
   
// Start the process of creating a sales order record.
var objRecord = record.create({
    type: record.Type.SALES_ORDER, 
    isDynamic: true,
    defaultValues: {
        entity: 87
    } 
});

// Start the process of creating an instance of a custom record type.
var customRecord = record.create({
    type: 'customrecord_feature',
    isDynamic: true                       
});

// Create a record with two default values 
record.create({
    type: record.Type.SALES_ORDER,
    defaultValues: {
        entity: 107,
        subsidiary: 1
    }
});
...
// Add additional code 

        

Related Topics

N/record Module
SuiteScript 2.x Modules
SuiteScript 2.x

General Notices