record.transform.promise(options)

Method Description

Transforms a record from one type into another asynchronously, using data from an existing record.

You can use this method to automate order processing, creating item fulfillment transactions and invoices off of orders.

For a list of supported transformations, see Supported Transformation Types.

Note:

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

Returns

Promise Object

Synchronous Version

record.transform(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 record types: 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.fromType

string

required

The record type of the existing record instance being transformed.

This value sets the Record.type property for the record. This property is read-only and cannot be changed after the record is loaded.

Set this value using the record.Type.

2015.2

options.fromId

number

required

The internal ID of the existing record instance being transformed.

2015.2

options.toType

string

required

The record type of the record returned when the transformation is complete.

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 transformRecord() {
    var transformRecordPromise = record.transform.promise({
        fromType: record.Type.ESTIMATE,
        fromId: 25,
        toType: record.Type.SALES_ORDER,
        isDynamic: true,
    });
    
    transformRecordPromise.then(function(recordObject) {    
        var recordId = recordObject.save();    
          // Add any other needed logic that shouldn't execute until
          // after the record is transformed.               
        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