Get Extension Assets Path with Default in SuiteScript

The getExtensionAssetsPathWithDefault helper provides a way to access extension assets in SuiteScript with a fallback option.

·1 min read·View Oracle Docs

The getExtensionAssetsPathWithDefault helper is essential for developers working with SuiteScript, particularly in customizing extensions. This helper aids in accessing assets that are pre-included with active extensions and ensures your templates have proper asset paths configured in NetSuite. If a specific asset path isn't available, this helper allows you to define a default fallback path.

How to Use getExtensionAssetsPathWithDefault

To utilize the getExtensionAssetsPathWithDefault helper in your templates, you need to provide two arguments:

  1. config_value: The path as configured in NetSuite.
  2. default_value: A fallback path to use if the asset isn't configured.

Example Syntax in a Template File:

You can include this helper in an HTML template as follows:

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

Example Result:

This helper effectively returns the active extension's asset path. If the first argument is defined, it retrieves the configured path:

html
<MY_PATH>/img/other_logo.png

If the config_value is undefined, the second argument is used to generate the correct path for the active extension:

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

This dual-path functionality is particularly useful for maintaining flexibility in your asset management, especially when deploying extensions across different environments.

Key Takeaways

  • The helper accesses pre-existing assets for active extensions.
  • It allows for configurable and fallback asset paths.
  • Useful for template customization in SuiteScript.

Frequently Asked Questions (4)

How do I use the 'getExtensionAssetsPathWithDefault' helper in a SuiteScript template?
To use 'getExtensionAssetsPathWithDefault', include it in your template with two arguments: 'config_value' for the path configured in NetSuite, and 'default_value' as a fallback if the first path is unavailable.
What arguments are required for the 'getExtensionAssetsPathWithDefault' method?
The 'getExtensionAssetsPathWithDefault' method requires two arguments: 'config_value', which is the path as configured in NetSuite, and 'default_value', which serves as the fallback path.
Can the 'getExtensionAssetsPathWithDefault' helper be used in all NetSuite environments?
Yes, the 'getExtensionAssetsPathWithDefault' helper is useful for maintaining flexibility and consistency in asset management across different NetSuite environments.
What happens if the 'config_value' path is undefined when using this helper?
If the 'config_value' is undefined, the 'getExtensionAssetsPathWithDefault' helper retrieves the 'default_value' as the fallback path for the active extension, ensuring assets are properly accessed.
Source: getExtensionAssetsPathWithDefault(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 SuiteScript

View all SuiteScript articles →