If I need to store a password in a custom record a...
# ask-stanley-ai
s
If I need to store a password in a custom record and I need to retrieve the value sometimes to refresh a token. What is the better way to do it?
c
AI generated answer (using internal Slack threads):
****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ****** If you need to store a password in a custom record and retrieve the value sometimes to refresh a token, there are a few ways you can do this in NetSuite: 1. Custom Record: You can store the password in a custom record. However, this method is not recommended for sensitive data as it is not secure. 2. Script Parameter: You can use a script parameter to store the password. This is a more secure method than using a custom record, but it is not as secure as using a credential field or secrets management. 3. Credential Field: This is a more secure option. You can use a Suitelet with
Form.addCredentialField()
to capture the password and save the returned handle to the credential (GUID). Then, you can refer to that GUID in your HTTPS request. NetSuite will replace the GUID with the actual password. 4. Secrets Management: This is the most secure option. You can create an Access Token secret and a Refresh Token secret. If the Access Token fails, you can use the Refresh Token to update the Access Token secret. Remember, if you are using the password in an HTTPS request, a credential field is the recommended option. If the data is not terribly sensitive, you might start with the custom record route. However, if you need to protect the access token, using secrets or credential fields is recommended. Here is a code sample for using Secrets Management:
Copy code
javascript
var secret = runtime.getCurrentScript().getParameter({name: 'custscript_my_secret'});
In this example,
custscript_my_secret
is the ID of the script parameter where you stored your secret. Please note that you cannot get the original value back from a password field. If you need to securely save a password, then retrieve the password plaintext for use elsewhere, hashing isn't the solution. You need to use
Form.addCredentialField()
.
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.830485523
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.818930328
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.818226159
Please provide your feedback on this answer.