ERP Lover
01/31/2025, 12:56 PMCeligo AI
01/31/2025, 12:56 PMAI generated answer (using internal Slack threads):In SuiteScript 2.1, you can use the
form.addCredentialField
method to add a credential field to a form. This method returns a GUID that you can use later to retrieve the stored credentials. Here's a general process for creating credential fields and then, later, getting their handles and passing them on using `nlapiRequestURLWithCredentials`:
1. Add two custom fields with username and passwords to a form:
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:
javascript
var credValue = nlapiGetFieldValue('custpage_credname');
var username = nlapiGetFieldValue('custpage_username');
nlapiSetFieldValue('custentity_custompassword', credValue);
nlapiSetFieldValue('custentity_customusername', username);
The domain field in form.addCredentialField
is the domain that the credentials will eventually be sent to. NetSuite will only send the credentials to the chosen domain.
Once you enter a value into the credential field, it will be replaced with a GUID. You can then use this GUID in your requests to a third-party endpoint.
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
01/31/2025, 12:57 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.817518532
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.815468907
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.811074138
Celigo AI
01/31/2025, 12:57 PM