keyControl.lock(options)

Note:

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

Method Description

Locks a key that has been uploaded to the Private Keys list in the UI or created using keyControl.createKey(options). Locked keys cannot be edited in the UI until they are unlocked with keyControl.unlock(options).

For more information, see Locking and Restricting Certificates.

Returns

void

Supported Script Types

Server scripts

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

Governance

10 units

Module

N/keyControl Module

Since

2021.1

Parameters

Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

Since

options.id

string

required

The script ID or internal ID for the key you want to lock. You can view the ID of a key from the Private Keys list at Setup > Company > Keys.

2021.1

Errors

Error

Thrown If

KEY_NOT_FOUND

The key with the ID provided does not exist in this account.

ACCESS_TO_KEY_RESTRICTED

The current employee or script does not have permission to access or edit the key. This can happen if the key is restricted to specific scripts or employees on the key record using the Restrict to Scripts or Restrict to Employees fields.

KEY_ALREADY_LOCKED

The key has already been locked.

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
...
//load the key object
var loadedKey = keyControl.loadKey({
    scriptId : 'custkey_testid'
});

//lock the key
loadedKey.lock({
    id: 'custkey_testid'
});

///save the key
loadedKey.save();
...
// Add additional code 

            

Related Topics

General Notices