getThemeAssetsPathWithDefault Helper in SuiteCloud

The getThemeAssetsPathWithDefault helper accesses theme assets in SuiteCloud, providing a fallback path when asset configuration is missing.

·2 min read·View Oracle Docs

The getThemeAssetsPathWithDefault function is an essential HTML template helper used in SuiteCloud to efficiently manage theme assets. It allows developers to access both new and existing assets within their theme directories, making it particularly useful for extension overrides and theme customizations.

This helper is invaluable when a configured asset path is expected but may not exist in NetSuite. It offers a way to designate a default path that will be utilized instead, ensuring continuity in asset display without causing breakage.

How Does It Work?

Using getThemeAssetsPathWithDefault, you provide two parameters:

  • config_value: This is the path set up in NetSuite for the asset.
  • default_value: This is the fallback path that will be used if the config_value is undefined.

Example Syntax in Template File:

Here’s how you would implement this in your HTML template:

html
<img src="{{ getThemeAssetsPathWithDefault logo_path 'img/logo.png' }}" >

Example Result:

The helper returns the asset path relative to the active theme. When the config_value is defined, it provides the configured path as follows:

html
<MY_PATH>/img/other_logo.png

If the config_value is not set, it falls back to the default_value, resulting in something like this:

html
<FULL_PATH>/extensions/<VENDOR>/<THEME_NAME>/<VERSION>/img/logo.png

This dual-path strategy ensures that developers maintain flexibility while preventing their themes from experiencing resource loading failures. Thus, getThemeAssetsPathWithDefault supports robust theming practices in SuiteCloud environments.

Key Considerations

  • Always ensure your default_value is correctly pointing to an accessible path to avoid any display issues.
  • Utilize this helper in your theme customizations to maintain integrity across various configurations.

With this approach, you can enhance both user experience and maintainability in your NetSuite environment.

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

Frequently Asked Questions (4)

How do you specify a fallback path using getThemeAssetsPathWithDefault?
When using the getThemeAssetsPathWithDefault function, you provide a 'config_value' for the expected asset path and a 'default_value' for the fallback path if the configured asset is not available.
What happens if the asset path is not configured in NetSuite when using getThemeAssetsPathWithDefault?
If the asset path is not configured, the getThemeAssetsPathWithDefault function uses the 'default_value' as the fallback, ensuring the application continues to display the necessary resources without interruptions.
Can getThemeAssetsPathWithDefault be used for theme customizations and extension overrides?
Yes, getThemeAssetsPathWithDefault is useful for managing both new and existing theme assets, making it particularly effective for theme customizations and extension overrides.
What are the parameters required for the getThemeAssetsPathWithDefault helper?
The function requires two parameters: 'config_value', which is the configured path, and 'default_value', which is the fallback path used if the 'config_value' is missing or undefined.
Source: getThemeAssetsPathWithDefault(config_value, default_value) 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 SuiteCloud Development Framework

View all SuiteCloud Development Framework articles →