record.attach.promise(options)

Method Description

Attaches a record asynchronously to another record.

Note:

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

Returns

Promise Object

Synchronous Version

record.attach(options)

Supported Script Types

Client scripts

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

Governance

10 units

Module

N/record Module

Since

2015.2

Parameters
Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

Since

options.record

record.Record

required

The record to attach.

2015.2

options.record.type

string

required

The type of record to attach.

Set the value using the record.Type enum.

To attach a file from the File Cabinet to a record, set type to file.

2015.2

options.record.id

number | string

required

The internal ID of the record to attach.

2015.2

options.to

record.Record

required

The record that the options.record gets attached to.

2015.2

options.to.type

string

required

The record type of the record to attach to.

Set the value using the record.Type enum.

To attach a file from the File Cabinet to a record, set type to file.

2015.2

options.to.id

number | string

required

The internal ID of the record to attach to.

2015.2

options.attributes

Object

optional

The name-value pairs containing attributes for the attachment.

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 attachRecord() {
    var attachRecordPromise = record.attach.promise({
        record: {
            type: record.Type.CONTACT,
            id: '97'
        },
        to: {
            type: record.Type.OPPORTUNITY,
            id: '16'
        }
    });
    
    attachRecordPromise.then(function() {                      
        // Add any other needed logic that shouldn't execute until
        // after the contact record is attached to the opportunity 
        log.debug({
         title: 'Record updated', 
         details: 'Attachment successful'
        });
                 
    }, function(e) {
        log.error({
            title: e.name, 
            details: e.message
        });
    });
}
...
// Add additional code 

        

Related Topics

General Notices