Form.addCredentialField(options)

Note:

The content in this help topic pertains to SuiteScript 2.0.

Method Description

Adds a text field that lets you store credentials in NetSuite to be used when invoking services provided by third parties. The GUID generated by this field can be reused multiple times until the script executes again.

For example, when executing credit card transactions, merchants need to store credentials in NetSuite that are used to communicate with Payment Gateway providers.

The credentials added with this method can be used with the N/sftp Module and the N/https Module.

Note the following about this method:

  • Credentials associated with this field are stored in encrypted form.

  • SuiteScript does not hold a credential in clear text mode.

  • NetSuite reports or forms will never provide the clear text form of a credential to the end user.

  • Any exchange of the clear text version of a credential with a third party must occur over an encrypted network transport of TLS 1.2 or SFTP. For more information about SFTP encryption, see Supported Cipher Suites and Host Key Types.

  • For no reason will NetSuite ever log the clear text value of a credential (for example, errors, debug message, alerts, system notes, and so on).

  • Decryption occurs though the scripts listed in the restrictToScriptIds parameter. These scripts can call https.createSecureString(options) to decrypt the GUID and create a SecureString instance.

Important:

The default maximum length for a credential field is 32 characters. If needed, use the Field.maxLength property to change this value.

Returns

serverWidget.Field object

Supported Script Types

SuiteScript 2.x Suitelet Script Type and SuiteScript 2.x User Event Script Type (beforeLoad(context))

Governance

None

Module

N/ui/serverWidget Module

Since

2015.2

Parameters
Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

Since

options.id

string

required

The internal ID of the credential field.

The internal ID must be in lowercase, contain no spaces, and include the prefix custpage if you are adding the field to an existing page.

2015.2

options.label

string

required

The label for the credential field.

2015.2

options.restrictToDomains

string | string[]

required

The domains that the credentials can be sent to, such as 'www.mysite.com'. Credentials cannot be sent to a domain that is not specified in this parameter.

This value can be a single domain or a list of domains.

Note:

Duplicate domain names in this parameter are not supported.

2015.2

options.restrictToScriptIds

string | string[]

required

The IDs of the scripts that are allowed to use this credential field. For example, 'customscript_my_script'.

Scripts defined in this parameter can call https.createSecureString(options) to decrypt the GUID.

Note:

Duplicate script ids in this parameter are not supported.

2015.2

options.restrictToCurrentUser

Boolean

optional

Controls whether use of this credential is restricted to the same user that originally entered the credential.

By default, the value is false, which means that multiple users can use the credential. For example, multiple clerks at a store making secure calls to a credit processor using a credential that represents the company they work for.

If set to true, the credentials apply to a single user.

2015.2

options.container

string

optional

The internal ID of the tab or field group to add the credential field to. By default, the field is added to the main section of the form.

2016.1

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/ui/serverWidget Module Script Samples. For a complete script sample that uses Form.addCredentialField, see N/https Module Script Samples.

          //Add additional code 
...
var form = serverWidget.createForm({
    title : 'Simple Form'
});
var credField = form.addCredentialField({
    id : 'username',
    label : 'Username',
    restrictToDomains : 'www.mysite.com',
    restrictToScriptIds : 'customscript_my_script',
    restrictToCurrentUser : false,
});
credField.maxLength = 64;
...
//Add additional code 

        

Related Topics

serverWidget.Form
N/ui/serverWidget Module
SuiteScript 2.x Modules
SuiteScript 2.x

General Notices