Refer to the following sections for details on SuiteScript updates for NetSuite 2023.2:
- 2023.2 SuiteScript Records Browser
- N/crypto/random Module
- Alternative Character Encoding for Files in Suitelet Responses
The 2023.2 SuiteScript Records Browser is not yet available.
N/crypto/random Module
The N/crypto/random Module provides cryptographically secure pseudorandom generator methods. This module provides the following methods:
- random.generateBytes(options) – Generates a cryptographically strong pseudorandom set of bytes.
- random.generateInt(options) – Generates a cryptographically strong pseudorandom number.
- random.generateUUID() – Generates a v4 Universally Unique Identifier (UUID) using a cryptographically secure random number generator.
With these methods, you can generate a random integer using a cryptographically secure pseudorandom number generator (CSPRNG). These methods should be used over Math.random for any values that should not be predictable such as: key generation, unique IDs, tokens, gambling, or statistical sampling.
Alternative Character Encoding for Files in Suitelet Responses
In SuiteScript 2.x, Suitelet textual responses are encoded in UTF-8 by default. If you want to return a file with an alternative character encoding, you can use the following modules in your script:
- N/file Module – Use file.create(options) to set the file encoding.
- N/https Module – Use ServerResponse.setHeader(options) to specify the same
charsetvalue in the Content-Type header. Then, call ServerResponse.writeFile(options) to return the file in the response.
ServerResponse.writeFile(options) now preserves the file’s encoding if the charset value specified in the header matches the file’s encoding.