contextData and contextDataRequest Properties in SuiteCommerce

contextData and contextDataRequest properties enhance SuiteCommerce extensions by managing data response handling seamlessly.

·2 min read·View Oracle Docs

The contextData and contextDataRequest properties are fundamental components used in developing SuiteCommerce extensions, enabling effective data management in various views.

What Are contextData and contextDataRequest?

  • contextData: This property is available in every view, but it is only populated with data in specific cases. It allows views, such as the product details page, to manage and utilize contextual information effectively.
  • contextDataRequest: This property can be used in child views that stem from views containing contextData. You can invoke contextDataRequest to retrieve an array of desired data types.

Supported Data Object Types

When utilizing these properties, views can return four different object types, as specified by their class. Setting this up properly is essential for the expected functionality of your extensions. Here’s a recap of the parent view classes associated with contextData:

Class AvailabilityInformation Returned
Facets.Browse.ViewThe category model
ItemRelations.RelatedItem.ViewThe item model
Facets.ItemCell.ViewThe item model
ProductDetails.Base.ViewThe parent model for a product, including the item model

Cascading Availability

The availability of contextData cascades through parent and grandparent views, ensuring child views can access necessary properties without direct inclusion in the top-level classes.

Best Practices to Follow

While developing extensions in SuiteCommerce and SuiteCommerce Advanced, be mindful of the following best practices:

  1. Avoid Extending childViews: In modern SCA versions, refrain from adding a child view by extending the childViews property to ensure stability and sustainability. Instead, utilize the Extensibility API effectively.
  2. Modifying Themes: If you’re using managed themes, do not customize core theme template files directly. Aim for extensions that preserve existing functionalities while adding new features, helping maintain consistency across updates.

Conclusion

Understanding and utilizing contextData and contextDataRequest properly can significantly improve the flexibility and performance of your SuiteCommerce extensions. These properties enable a more organized approach to handling data, especially for complex views like product detail pages.

Key Takeaways

  • contextData serves as a crucial link for accessing contextual data in views.
  • contextDataRequest allows child views to specify data needs dynamically.
  • Avoid practices that lead to unmaintainable extensions, such as modifying core theme templates.
  • Cascading availability allows for efficient property access across nested views.

Frequently Asked Questions (4)

Is the use of SCView mandatory in SuiteCommerce extensions?
While the transition to SCView from Backbone.View is recommended starting from SuiteCommerce Advanced 2020.2.0, it ensures enhanced methods and better development practices.
What permissions are required to create a new view file in SuiteCommerce?
The article does not specify permissions required for creating a new view file. Typically, you would need appropriate access rights to the development environment and the project's source code.
How does SCView handle context in a SuiteCommerce extension?
SCView uses the getContext method to provide the context for the template, allowing it to access item data dynamically through the contextData object.
Can the render method in SCView be overridden for all display types?
No, the render method in SCView is protected and should only be overridden for specific display types, such as 'list', as indicated by the current display in the PLP component.
Source: Create the View File 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 →