Understanding Catalog Variables in ServiceNow - ben-vargas/servicenow-wiki GitHub Wiki

This article explains how catalog variables function within ServiceNow's Service Catalog, outlining the relationships between various catalog components using the provided diagram. Understanding these relationships is crucial for designing effective and user-friendly catalog items.

Overview

The provided diagram depicts the flow and connections between several key ServiceNow tables and their relationships to Catalog Variables. These components together build the data model for service catalog items, allowing users to create requests, provide input, and manage configurations.

Key Components

The following components are highlighted in the image and described below:

  1. document:
    • This represents a generic document that may be associated with a Question Answer, as it the parent of the question answer table.
  2. Question Answer [question_answer]:
    • This table stores the responses to questions asked in a catalog item. It is related to both the document and the Question tables.
  3. Question [question]:
    • This table stores the definitions of questions used in catalog items, it is the parent of the variable table and the Question Choice table.
  4. Question Choice [question_choice]:
    • This table stores the predefined choices for specific questions, often presented as a list. It is related to the Question table. It has a "no link" line leading to the Options table in the diagram, which likely means there is no direct database relationship.
  5. Variable [item_option_new]:
    • This table is a core component for catalog variables. This table stores the specific attributes and configurations of variables (input fields) within a catalog item.
    • It extends the Question table, adding extra functionality to the base question functionality.
    • It is directly related to the Variable Set and Catalog Item tables.
  6. Variable Set [item_option_new_set]:
    • This table allows for grouping of variables together so they can be reused across different catalog items, acting as a collection of variables.
    • It is related to the Catalog Variable Set table and the Catalog Item table.
  7. Catalog Variable Set [io_set_item]:
    • This table defines the reusable variable sets that can be added to catalog items, and other record producers.
    • The relationship to the Variable Set table is that catalog_variable points to the sys_id of the variable set
  8. Catalog Item [sc_cat_item]:
    • This table defines the actual catalog items that users interact with when submitting a request, it has relationships to the variables and variable sets.
  9. Variables [sc_item_variables_task]: * This table links a Requested Item to the different Variables that are configured in the service catalog, in order to save the values for those variables
  10. Catalog Task [sc_task]:
    • This is the table that will create a task based on an item being requested. This is directly related to the Requested Item table, it is created as part of a Requested Item.
  11. Variable Ownership [sc_item_option_mtom]:
    • This many-to-many relationship table is used to link specific options to the variables on the form, where specific options exist for variables. This links options on the Options table to the Variable table.
  12. Requested Item [sc_req_item]:
    • Represents an individual line item in a catalog request. This item is the parent of the Catalog Task table, and is related to the Cart Item table.
  13. Options [sc_item_option]:
    • This table defines the different options for a question of type "Choice", and is linked to the Cart Item via a Cart Item reference field.
  14. Cart Item [sc_cart_item]:
    • This represents an item that exists in the service catalog cart prior to the checkout. This has a relationship with the Shopping Cart table, and the Options table.
  15. Shopping Cart [sc_cart]:
    • This table represents the users shopping cart and contains the relationship to the Cart Item table.
  16. Catalog UI Policy [catalog_ui_policy]:
    • Defines UI policies that affect the user interface based on the values of variables in a form.
    • UI Policies are connected to the catalog item via reference field on this table.
  17. Catalog UI Policy Action [catalog_ui_policy_action]:
    • Defines the actions performed by a catalog UI Policy, such as making a field visible, hidden, read-only or mandatory.
    • UI Policy actions are connected to a UI Policy and a variable with a reference to that variable.

Relationships and Flow

Here's a breakdown of how these components work together:

  1. Defining Variables:
    • Administrators create variables in the Variable [item_option_new] table. They can configure their type, display name, help text, and other properties, including validation scripts to ensure proper input.
  2. Organizing with Variable Sets:
    • Variables can be grouped into reusable Variable Sets in Variable Set [item_option_new_set]. These are stored in the Catalog Variable Set [io_set_item] table, and then linked to specific catalog items, making it easier to share a common set of variables.
  3. Building the Catalog Item:
    • When creating a catalog item (Catalog Item [sc_cat_item]), you can associate it with Variable Sets and individual variables, by adding the Variable or Variable Set to the form.
  4. User Interaction:
    • When a user accesses the catalog item, the defined variables render as interactive input elements on the catalog form.
    • As users interact with the UI, the choices in Question Choice [question_choice] are displayed if a question type is "Choice".
  5. Request Submission:
    • When a user submits a request, the entered values are stored in Question Answer [question_answer] or the values are placed into the Variables [sc_item_variables_task] table linking the variables to the Requested Item and are also stored within the Cart Item records.
    • The Requested Item [sc_req_item] record is created, which includes the values from variables specified by the user, and contains a reference to the Shopping Cart [sc_cart] and Cart Item [sc_cart_item] records.
    • Catalog Task [sc_task] records are created as part of the workflow defined for the Requested Item.
  6. UI Policies:
    • Catalog UI Policy [catalog_ui_policy] records are created and associated with a catalog item, they are configured with conditions based on values in variables on the form.
    • Catalog UI Policy Action [catalog_ui_policy_action] records are linked to a UI policy and define actions (such as setting visibility, read-only, or mandatory status) on variables, based on a condition on the form.

Additional Notes

  • (link can be removed without deleting data for old requested items): This note in the diagram indicates that there is some type of many-to-many relationship or other complex data model where the connection between the entities can be removed and the history of the values can still be retained in the older records.
  • (catalog_variable (String)): Represents the relationship between the Catalog Variable Set and the Variable Set and shows that the field in the Catalog Variable Set points to a record in the Variable Set table.
  • Record Producers: Though not fully detailed in this image, Record Producers are another type of catalog item. The image has Record Producers - sc_item_produced_record, which points to the task table, Producer -> sc_cat_item_producer, which links the record producer to a catalog item, question_answer, for the answers provided, table_sys_id, representing the source record. Then also references the Question --> item_option_new which represents the Variable table and the value for the variable.

Key Takeaways

  • Variables are Fundamental: Catalog variables are central to capturing user input in a structured manner.
  • Variable Sets for Reuse: Variable sets promote reusability and consistency across catalog items.
  • Relationships are Crucial: Proper configuration of relationships between these different components ensures correct functionality of the service catalog.
  • Dynamic Behavior: UI Policies and actions allow for dynamic modifications of the UI based on variable selections.