When using form.addCredentialField(options) , how ...
# ask-stanley-ai
e
When using form.addCredentialField(options) , how do I read the credential at a later stage?
c
AI generated answer (using internal Slack threads):
Based on the conversations, to read the credential at a later stage after using
form.addCredentialField(options)
, you would use the
nlapiGetFieldValue('custpage_credname')
function. This function will return a GUID (Globally Unique Identifier) which represents the stored credential. Here is a step-by-step process: 1. Add the credential fields to a form:
Copy code
javascript
var credField = form.addCredentialField('custpage_credname', 'password', null, valueFromCustomField, '<http://cert.merchante-solutions.com|cert.merchante-solutions.com>', 'customscript_usecredentialfield');
var usrfield = form.addCredentialField('custpage_username', 'username', null, valuefromusernamecustfield, '<http://cert.merchante-solutions.com|cert.merchante-solutions.com>', 'customscript_usecredentialfield')
2. During a beforeSubmit user event, obtain the values from credential fields and store them in two custom fields, which are not visible on the form:
Copy code
javascript
var credValue = nlapiGetFieldValue('custpage_credname');
var username = nlapiGetFieldValue('custpage_username');
nlapiSetFieldValue('custentity_custompassword', credValue);
nlapiSetFieldValue('custentity_customusername', username);
The GUID can then be used in subsequent API calls. The actual credentials are securely stored by NetSuite and are not accessible directly. The GUID is used as a reference to these credentials. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.811034501
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.803880632
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.793886065
Please provide your feedback on this answer.