Open state management

  • Release version: Washingtondc
  • Updated May 6, 2024
  • 2 minutes to read
  • Summarize
    Summarized using AI
    This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.

    Summary of Open State Management

    The Open State Management framework within the Configuration State Model API allows developers to program variations in product options displayed in the product configurator for Sales and Order Management. It enables control over the visibility and editability of nodes in the user interface based on specific events, enhancing the configurator’s functionality without needing extensive JSON scripting.

    Show full answer Show less

    Key Features

    • State Control: Manage node visibility (Yes/No) and editability (Yes/No) for various product attributes.
    • Events Framework: Utilize two primary events: On Load (initial state setting) and On Change (state changes based on user interactions).
    • Helper API Methods: Access a set of methods to read and set states for product characteristics, including:
      • Getter Methods:
        • getAllNodes(): Retrieves all node paths and their states.
        • getNode(nodePath): Fetches states for a specified node.
      • Setter Methods:
        • setVisible(nodePath, True/False): Sets visibility for a node.
        • setEditable(nodePath, True/False): Sets editability for a node.
      • Context Variable Methods:
        • getHeaderContextVariables(): Lists all header context variables.
        • getLineContextVariables(): Lists all line context variables.

    Key Outcomes

    By effectively utilizing the Open State Management framework, ServiceNow customers can tailor the product configurator experience to meet specific business rules and customer needs. This results in improved user experience, compliance with regulations, and optimized product selection based on customer attributes.

    The open state model is a programmatic framework in the Configuration State Model API, which enables you to program variations in product options that appear in the product configurator in Sales and Order Management. The API framework provides certain states and helper API methods for controlling how nodes in the product configurator user interface are displayed.

    As developers, you can use extension points for open state management to set the view-only or editable states on any configurator node, based on events that occur at loading or when product selections change. Various helper API methods are available for reading and setting states on any node, eliminating the need for extensive JSON scripting.
    Note:
    Check your entitlements to determine if you have access to these features.

    Use cases for configuration state management

    The following table shows different ways that you can control the product options displayed in the product configurator.
    Table 1. Configuration state model use case examples
    Product configurator use case Example
    Hide certain options for a customer A product attribute selection isn’t displayed for customers in California due to state safety regulations​.
    Set certain default options for a customer For upgrades, only the Ultimate plan is displayed for existing customers who have a premium plan.
    Allow only certain options to be selected based on other attribute options For certain products such as laptops, display all sizes 13", 15", and 17", but display only 15" and 17" laptops if only the touchscreen feature is required.

    You can manage the display of options in the product configurator by using the Configuration State Model API Framework.

    Framework overview

    Manage the following states using the Configuration State Model API Framework:
    • Visible - Yes (make node visible) or No (make node invisible).
    • Editable - Yes (show node and make it selectable) or No (show node but make it unselectable).
    These states can be activated using these two events in the Events Framework of the Configuration State Model:
    • On Load - The state (visibility, editability) of each node is initially set to Yes (true). The open state is invoked on loading.
    • On Change - This function is called whenever there’s a change in a node's value in the product configurator user interface. However, this state isn’t invoked when quantity changes occur in the product configurator.
    Figure 1. State management key concepts
    Diagram that shows key concepts of state management including editable state and visible states.

    Helper API methods

    You can use the following helper API methods to read and set states on any node:
    Apply states
    Set the visible and editable states for product relationship groups, product characteristics, and product characteristic options using Getter and Setter methods to read and change the state of the configuration model.
    Getter methods
    Obtain node paths along with the states on any configuration node:
    • getAllNodes(): Returns JSON with node path (reference to code) and its respective relative path with all the states.
    • getNode(nodePath): Return all the states for the specified node path if it exists.
    Setter methods
    Set the visible and editable states for product relationship groups, product characteristics, and product characteristic options.
    • setVisible: True/False at all levels
    • setVisible(nodePath, True/False)
    • setEditable: True/False at all levels
    • setEditable(nodePath, True)
    Getter context variable methods
    Retrieve context variables inside the product configurator user interface.
    • getHeaderContextVariables(): Returns a list of all the header context variables.
    • getHeaderContextVariableValue(contextVariable): Returns a value and display value of a specific context variable in the header.
    • getLineContextVariables(): Returns a list of all the line context variables.
    • getLineContextVariableValue(nodePath, contextVariable): Returns the value of a specific context variable in the line.