Access Configuration Properties

This topic applies to

Applies to

SuiteCommerce Web Stores

 

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.

Obtain the Entire Configuration Object

In some cases, you might want to obtain the entire configuration. One example of this use case is to inspect the configuration object to find a specific property or property value. To obtain the entire configuration object as a JavaScript object, leave the key empty.