Guidelines for Working with Core Modules in SuiteCommerce

Understand best practices for working with core modules in SuiteCommerce extensions to ensure compatibility and stability.

·2 min read·View Oracle Docs

TL;DR

When developing extensions for SuiteCommerce websites, it is crucial to avoid direct involvement with core modules to ensure compatibility with future SuiteCommerce updates. Following specific guidelines can help maintain the functionality and stability of your extensions.

Best Practices When Working with Core Modules

When extending SuiteCommerce, it is essential to adhere to specific guidelines to avoid potential problems with future updates or cross-usage with other websites. Here are some best practices:

  • Avoid Direct Inclusion: Do not include core modules in a require() or define() statement.
  • Avoid Extending Core Modules: Refrain from using extend() to add or overwrite methods or properties of core modules.
  • No Method Wrapping: Do not use _.wrap() to modify the output of core module methods.
  • Prototype Modifications: Avoid modifying the prototype of core modules. Opt for methods such as:
    • Use addChildView() to add a child view instead of using SomeView.prototype.childViews.MyChildView.
    • Use addToViewContextDefinition() for adding properties to a view's context object rather than altering the method SomeView.prototype.getContext.MyNewProperty.

Production Code Guidelines

In any production code, the following guidelines should be followed:

  • Accessing Private Methods: Use application.getLayout() to access a core module or object's private methods instead of accessing application._layoutInstance.
  • Avoid Global Variables: Do not access the SC global variable in your extensions.
  • Use Overrides: Instead of editing core modules directly, always use overrides where necessary.

Following these guidelines will help you create more robust and future-proof extensions in the SuiteCommerce environment, ensuring your development efforts are not undermined by changes in core modules as new versions roll out.

Key Takeaways

  • Avoid direct access and modifications to core modules for stability.
  • Utilize provided methods like addChildView() and addToViewContextDefinition() for modifications.
  • Use overrides instead of editing core modules directly to maintain compatibility.
  • Strictly adhere to guidelines to prevent issues with future SuiteCommerce updates.

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

Frequently Asked Questions (4)

Can I directly include SuiteCommerce core modules in my extensions?
No, you should not include core modules directly using `require()` or `define()` statements. This could lead to compatibility issues with future SuiteCommerce updates.
How should I add a child view to a core module in SuiteCommerce?
You should use the `addChildView()` method instead of directly modifying the `SomeView.prototype.childViews` object.
What is the recommended way to modify a view's context object in SuiteCommerce?
You should use `addToViewContextDefinition()` to add properties to a view's context object rather than altering the method directly on the prototype.
Is it okay to access the SC global variable in SuiteCommerce extensions?
No, it is recommended to avoid accessing the `SC` global variable in your extensions to maintain stability and future compatibility.
Source: Working with Core Modules 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 Commerce

View all Commerce articles →