Access Configuration Properties

The SuiteCommerce Configuration is a record in your NetSuite account that lets you configure properties without customizing source code. You access the record through NetSuite to configure common properties and modify application behavior for a specified domain. For more information about this record, see Configure Properties.

Note:

The SuiteCommerce Configuration record is part of the SuiteCommerce Configuration SuiteApp.

You can build your extension to access any configuration property value for the associated domain using the getConfig(key) method of EnvironmentComponent. The key parameter is the ID of a property in the configuration record. The method returns a string, array, object, or Boolean, depending on the configuration property. For more information about the configuration properties and their respective IDs, see Configuration Properties Reference.

The following example shows how to use the getConfig(key) method to access the value of the checkoutApp.skipLogin property:

          var environmentComponent = container.getComponent('Environment');
var skipLogin = environmentComponent.getConfig('checkoutApp.skipLogin'); 

        

In the above example, the skipLogin variable can be true or false, depending on whether the Skip Checkout Login property is enabled for the domain.

Guidelines for getConfig(key)

Read and understand the following guidelines when working with the getConfig(key) method:

Dot-Notation

You can use dot-notation to access the hierarchy of configuration properties. For example, using getConfig(‘checkoutApp’) will return a JavaScript object that contains the skipLogin property value.

You can also access the hierarchy of configuration properties by string value or by name. All three of the following API calls return the value of the skipLogin property:

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

            

Read-Only Values

The getConfig() method returns a copy of the configuration or configuration property. As a result, values for configuration properties are read-only. To make changes to a configuration property, you must change the property using the SuiteCommerce Configuration record. See Site Configuration for details.

Avoid using getConfig() without a key

Although it is possible to use getConfig() without specifying a key, it is not recommended. If you do not specify a key, the application attempts to return the entire configuration object. On some pages in the application, this may return a very large object, which will result in an internal error (InternalError: too much recursion) or a range error (RangeError: Maximum call stack size exceeded).

Related Topics

Do More With Extensions
Localize Text in an Extension
Extensions for Site Management Tools (SMT)
Modal Dialogs in SCIS
Implement Asynchronous and Synchronous Methods
Make a View Available Anywhere in Your Templates

General Notices