Frontend Models in SuiteCommerce for Robust Data Handling

Frontend models in SuiteCommerce use Backbone.js to manage data efficiently, ensuring smooth interactions between users and NetSuite.

·2 min read·View Oracle Docs

Frontend models are essential components used by SuiteCommerce Advanced (SCA) to handle data within the MVC (Model-View-Controller) architecture. Built upon the Backbone.js framework, each frontend model is an extension of Backbone.Model, which provides default, inheritable methods accessible to all models in SCA. Developers can override these methods to suit specific requirements of their applications, such as modifying the initialize method to set model-specific properties.

Important Note: For users customizing SCA from version 2020.1 and onward, it's recommended to utilize SCModel instead of Backbone.Model, as SCModel encapsulates the necessary enhancements for better performance within SuiteCommerce.

Frontend models can be categorized in two main ways:

  1. Feature-specific Models: These are defined by returning an object that contains the model. They can be created using the following syntax:
    javascript
    return Backbone.Model.extend
  2. Wider Application Models: These models are accessible throughout various modules of the application. They can be initialized with the following syntax:
    javascript
    ProfileModel = Backbone.Model.extend
    By using this approach, the ProfileModel can be utilized by multiple modules requiring access to user profile data. Typically, these models are designed as singletons to ensure only one instance exists per user session.

When initializing a model through a router or view, developers can pass necessary properties for that model, whether for internal use or for backend data management.

General Functions of Frontend Models

Frontend models handle several crucial tasks, including:

  • Setting the initial values of properties
  • Defining methods specific to the model
  • Overriding default methods for customization
  • Performing validation on user-submitted data on the frontend

Common Properties of Frontend Models

Every frontend model typically includes the following properties:

  • urlRoot: Indicates the backend service URL used for HTTP requests, represented as a string containing a partial URL.
  • validation: An object that defines validation rules for properties when users submit form data.

Understanding and utilizing frontend models effectively can significantly enhance the development experience in SuiteCommerce and improve data management and user interactions while leveraging the powerful Backbone.js framework.

Frequently Asked Questions (4)

Should I use SCModel or Backbone.Model for customizations in SCA 2020.1 or later?
For SuiteCommerce Advanced version 2020.1 and later, you should use SCModel, which is SuiteCommerce's customized alternative that inherits from Backbone.Model.
How can frontend models in SCA be customized?
Frontend models can customize behavior by overriding core methods of Backbone.Model, such as the initialize method, to meet specific application requirements.
What is the purpose of the urlRoot property in frontend models?
The urlRoot property specifies the backend service that manages HTTP requests for the model, and it is formatted as a string containing a partial URL.
What types of frontend models are used in SuiteCommerce Advanced?
Frontend models in SCA are typically divided into feature-specific models, which use Backbone.Model.extend syntax, and application context models, which require initialization to populate data.
Source: Frontend Models 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 General

View all General articles →