record.copy.promise(options)

Method Description

Creates a new record asynchronously by copying an existing record in NetSuite.

Note:

The parameters and errors thrown for this method are the same as those for record.copy(options). For more information about promises, see Promise Object.

Returns

Promise Object

Synchronous Version

record.copy(options)

Supported Script Types

Client scripts

For more information, see SuiteScript 2.x Client Script Type.

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.

Use the following guidelines:

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

  • When copying 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.id

number

required

The internal ID of the existing record instance in NetSuite.

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.

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 promise script example, see Promise Object.

          // Add additional code
...
function copyRecord() {

    // Copy an instance of a standard record type.
    var copyRecordPromise = record.copy.promise({
        type: record.Type.PHONE_CALL,
     id: 165
    });
    
    // Note: To copy an instance of a custom record type,
    // use the record type's string ID instead of the record
    // module's Type enum. For example:
    // type: 'customrecord_feature'  

    copyRecordPromise.then(function(recordObject) {   
        recordObject.setValue({
            fieldId: 'title',
         value: 'Sprint 5 bug triage'
    });
            
        recordObject.setValue({
            fieldId: 'message',
         value: 'Please review the PowerPoint prior to the call.'
     });
                        
        var recordId = recordObject.save();
                
      // Add any other needed logic that shouldn't execute until
      // after the record is copied
        log.debug({
          title: 'Record saved', 
          details: 'Id of new record: ' + recordId
     });
                 
    }, function(e) {
        log.error({
            title: e.name, 
        details: e.message
     });
    });
}
...
// Add additional code 

        

Related Topics

General Notices