keyControl.createKey(options)

Note:

The content in this help topic pertains to SuiteScript 2.0 and SuiteScript 2.1.

Method Description

Creates a key record on the Keys page using a file from the File Cabinet.

Returns

keyControl.Key

Supported Script Types

Server scripts

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

Governance

10 units

Module

N/keyControl Module

Since

2019.2

Parameters

Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

Since

options.file

file

required

The internal ID of the File Cabinet file with the key.

The key must be in PEM format.

2019.2

options.name

string

required

The name of the key.

2019.2

options.description

string

optional

The description of the key.

2019.2

options.password

string

optional

The password that is associated with the key. The script ID of an API secret is accepted for this value. For more information, see Secrets Management.

2019.2

options.scriptId

string

optional

The script ID for the newly-created key.

NetSuite prepends this ID with ‘custkey’. If you do not provide an ID, one is auto-generated.

2019.2

options.restrictions

number[] or string[]

optional

The array of employee internal IDs selected in the Restricted to Employees field for a key.

If you select employees, only those employees can use this key.

2019.2

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/keyControl Module Script Samples.

              // Add additional code
... 
require(['N/keyControl','N/file'],function(keyControl,file){
    var key = keyControl.createKey();
    key.file = file.load(422); 

    //id of file containing private key (id_ecdsa or id_rsa)
    key.name = "SFTP key";
    key.save();
})
...
// Add addtional code 

            

Related Topics

General Notices