Form.addCredentialField(options)
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:
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 |
Suitelets User event scripts -beforeLoad entry point For more information, see SuiteScript 2.x Script Types. |
Governance |
None |
Module |
|
Since |
2015.2 |
Parameters
The options parameter is a JavaScript object.
Parameter |
Type |
Required / Optional |
Description |
Since |
---|---|---|---|---|
|
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 |
|
string |
required |
The label for the credential field. |
2015.2 |
|
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 |
|
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 |
|
Boolean |
optional |
Controls whether use of this credential is restricted to the same user that originally entered the credential. By default, the value is If set to |
2015.2 |
|
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
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