getConfig Method Guidelines for SuiteCommerce Configuration

Understand the getConfig method for SuiteCommerce, emphasizing read-only values and best usage practices.

·1 min read·View Oracle Docs

The getConfig(key) method is essential for accessing configuration properties within SuiteCommerce. Here are some crucial guidelines on how to use this method effectively:

Dot-Notation

You can easily access the hierarchy of configuration properties using dot-notation. For instance, calling getConfig('checkoutApp') will yield a JavaScript object that contains the skipLogin property value. The following API calls all retrieve the value of the skipLogin property:

javascript
getConfig('checkoutApp.skipLogin')
getConfig('checkoutApp').skipLogin
getConfig().checkoutApp.skipLogin

Read-Only Values

It’s important to note that the getConfig() method returns a copy of the configuration or configuration property, meaning that the values are read-only. If you wish to modify a configuration property, you'll need to do so through the SuiteCommerce Configuration record. For guidance, refer to the Site Configuration documentation.

Avoid Using getConfig() Without a Key

Although using getConfig() without specifying a key is an option, it’s generally discouraged. Without a key, the application attempts to return the entire configuration object, which may result in an excessively large object on certain pages, potentially causing an internal error (e.g., InternalError: too much recursion) or a range error (e.g., RangeError: Maximum call stack size exceeded).

By following these guidelines, you can effectively utilize the getConfig() method while avoiding common pitfalls associated with read-only values and overloading the configuration object.

Source: This article is based on Oracle's official NetSuite documentation.

Frequently Asked Questions (4)

Can I modify configuration properties retrieved using the getConfig method in SuiteCommerce?
No, the getConfig method returns read-only values. To modify configuration properties, you must update them through the SuiteCommerce Configuration record.
What happens if I use getConfig() without specifying a key?
Using getConfig() without a key is discouraged because it attempts to return the entire configuration object, which can be extremely large and might cause internal errors like too much recursion or maximum call stack size exceeded.
Is dot-notation supported when accessing configuration properties with getConfig?
Yes, dot-notation can be used to access the hierarchy of configuration properties. For example, getConfig('checkoutApp.skipLogin') will retrieve the skipLogin property value.
Why is it advised to avoid using getConfig() without a key in SuiteCommerce?
Without a key, getConfig() tries to retrieve the entire configuration object, which can be large and cause application errors due to excessive size.
Source: Guidelines for getConfig(key) Oracle NetSuite Help Center. This article was generated from official Oracle documentation and enriched with additional context and best practices.

Was this article helpful?

More in General

View all General articles →