Skip to main content

SuiteScript Updates in NetSuite 2021.2

2021.2 SuiteScript |

Refer to the following sections for details on SuiteScript updates for NetSuite 2021.2:

  • Workbook API Is Now Generally Available
  • New SecureString.replaceString Method Added to https.SecureString
  • https.SecureString Method Parameters Have Changed
  • MD5 and SHA1 Hash Algorithms Are No Longer Valid
  • Changes to nlapiEncrypt, CurrentRecord.getValue, and Record.getValue for Custom Password Fields
  • 2021.2 SuiteScript Records Browser

Workbook API Is Now Generally Available

The Workbook API is now generally available in this release. The Workbook API supports a wide range of features that let you build SuiteAnalytics datasets and workbooks using SuiteScript. The N/dataset module lets you build datasets, and you can use columns, joins, and conditions to filter your data. The N/ workbook module lets you build workbooks using analytics concepts such as data measures, calculated measures, and data dimensions. You can also use the N/workbook module to create pivot tables to analyze your data. features:

  • Dataset saving - You can now save your datasets using the new Dataset.save() method in the N/ dataset module. This method lets you save a dataset with a name and, optionally, a custom ID and description. You can use this method to save a new dataset, but you cannot use it to update an existing dataset (the dataset name and ID must be unique each time you call Dataset.save()).
  • Dataset linking - You can use the new N/datasetLink module to logically join two datasets and use data from both datasets in your pivots. Linking datasets is useful when you cannot use joins in the

SuiteAnalytics Workbook UI or the Workbook API to join record types explicitly. Linking datasets does

not merge the datasets. Instead, you specify an expression (which usually corresponds to a common column that is shared between the two datasets), and this expression is used to link the datasets. After datasets are linked, you can access all of the data in both datasets to use in workbooks. For more information, see Dataset Linking in SuiteAnalytics Workbook.

  • Pivot execution - After you define a pivot table for your data, you can now run the pivot and retrieve the results using the new Workbook.runPivot() method in the N/workbook module. This method always returns the full results of the pivot, but it can include different data types (such as a record, record key, range, or currency) depending on the pivot. You can run pivots synchronously or asynchronously in server scripts using the N/task module, or you can run pivots synchronously or using promises in client scripts. You can also run a pivot ad-hoc without a predefined dataset or workbook.
  • Conditional formatting - You can change the format of cells in pivot tables based on conditions that you specify. You can change the color, font style, or font weight to highlight cells that meet certain conditions. You can also define multiple formatting rules for a cell.

Change

For more information, see the help topic Workbook API (Beta). New SecureString.replaceString Method Added to https.SecureString The https.SecureString object has a new method: SecureString.replaceString(options). This method is used to replace all occurrences of a pattern string inside an https.SecureString with a replacement string. The updated string is returned. https.SecureString Method Parameters Have Changed To support more secure functionality of the https.SecureString object, the parameters in the following methods have been changed or added:

  • The SecureString.appendSecureString(options) method now includes the options.keepEncoding parameter to keep the appended string in its original encoding.
  • The SecureString.appendString(options) method now includes the options.keepEncoding parameter to keep the appended string in its original encoding. You should use the SecureString.appendString(options) method only for appending a string (UTF-8) to a SecureString.
  • The SecureString.convertEncoding(options) method now includes the options.fromEncoding parameter to specify the original encoding to convert from.
  • The SecureString.hash(options) method now includes the options.contentEncoding and options.resultEncoding parameters to specify the encoding to be used for the SecureString and the resulting hash string.
  • The SecureString.hmac(options) method now includes the options.contentEncoding and options.resultEncoding parameters to specify the encoding to be used for the SecureString and the resulting HMAC string. For complete information on all parameters for SecureString methods, see the help topic https.SecureString.

MD5 and SHA1 Hash Algorithms Are No Longer Valid

Support for the MD5 and SHA1 hash algorithms in SuiteScript 1.0 and SuiteScript 2.x are no longer valid. This change affects the following SuiteScript 1.0 method and SuiteScript 2.0 APIs and objects:

Method, API, or Object Description

nlobjCredentialBuilder(string, Use of the md5() and sha1() functions results in an error: domainString) HASHING_ALGORITHM_NO_LONGER_VALID. The hmac(context, credential, algorithm) function works only if the last parameter is sha256 or sha512: nlobjCredentialBuilder(data, domain).hmac(nlapiGetContext(), ‘my secret key’, ‘sha256’)). certificate.HashAlg The SHA1 value for certificate.HashAlg is no longer valid. This change affects the options.algorithm parameter of the certificate.createSigner(options), certificate.createVerifier(options), and certificate.signXml(options) methods. Change Method, API, or Object Description Use of the SHA1 value results in an error: HASHING_ALGORITHM_NO_LONGER_VALID. crypto.HashAlg The MD5 and SHA1 values for crypto.HashAlg are no longer valid. This change affects the options.algorithm parameter of the crypto.createCipher(options), crypto.createDecipher(options), crypto.createHash(options), and crypto.createHmac(options) methods. Use of the MD5 and SHA1 values results in an error: HASHING_ALGORITHM_NO_LONGER_VALID. https.HashAlg The MD5 and SHA1 values for https.HashAlg are removed. This change affects the options.algorithm parameter of the SecureString.hash(options) and SecureString.hmac(options) methods. Use of the MD5 and SHA1 values willresults in an error: HASHING_ALGORITHM_NO_LONGER_VALID. Scripts that use MD5 or SHA1 as the hash algorithm must be updated to use a different hash algorithm, such as SHA256 or SHA512, to ensure these scripts continue to work as expected after the upgrade to 2021.2. Changes to nlapiEncrypt, CurrentRecord.getValue, and

Record.getValue for Custom Password Fields

The use of the SuiteScript 1.0 nlapiEncrypt(s, algorithm, key) function for custom password fields is no longer supported. You should not use the SuiteScript 2.x CurrentRecord.getValue(options) and Record.getValue(options) methods for custom password fields. You can now use nlapiCheckPasswordField(type, id, value, field, sublist, line) for custom password fields in SuiteScript 1.0 and crypto.checkPasswordField(options) for SuiteScript 2.x custom password fields. For more information, see Upcoming Changes to Supported APIs for Checking Custom Password Fields (SuiteAnswers ID 97620). 2021.2 SuiteScript Records Browser The 2021.2 SuiteScript Records Browser is not yet available.