Milcho Dimkov
09/21/2024, 10:05 AMCeligo AI
09/21/2024, 10:06 AMAI generated answer (using internal Slack threads):To use "API Secrets" in SuiteScript, you can leverage the Secrets Management feature of NetSuite. This feature allows you to securely store sensitive data such as API keys, and then programmatically access them without exposing the secret data. Here's a general approach on how to use it: 1. First, you need to create the secret. This is done through the NetSuite UI, not programmatically. You can refer to this article for more details: https://system.netsuite.com/app/help/helpcenter.nl?fid=section_160216498405.html 2. Once the secret is created, you can use it in your SuiteScript. The secret is treated similarly to a GUID. It's used as a template expression that the N/https module replaces with the credential. 3. To retrieve the secret in your SuiteScript, you can use the
https.createSecureString
method. This method is only applicable to server-side scripts. Here's an example:
javascript
var token = https.createSecureString({input:'{custsecret_my_secret_id}'});
4. If you need to use the secret in a client-side script, you can't directly use the secret. However, you can have the client script call a Suitelet, which is server-side, and then use the secret in the Suitelet.
5. If you need to store a secret that you get from an external source through an API call, you can use the Form.addCredentialField
method in a user event script deployed on a custom record to create a credential field. Then, create that record in a script while using dynamic mode so that you can set the credential field and then get back its GUID.
Please note that the actual secret's contents are not printed in debug logs on the server's side, and they are not returned in the response to the client script.
******
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
09/21/2024, 10:07 AMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.859210849
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.853532255
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.851122379
Celigo AI
09/21/2024, 10:07 AM