Dynamic Schema

  • Release version: Yokohama
  • Updated January 30, 2025
  • 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 Dynamic Schema

    The Dynamic Schema feature in the Yokohama Release allows ServiceNow customers to define a flexible and hierarchical metadata structure consisting of categories, groups, and attributes. This approach lets users capture dynamic attribute-value pairs on records without adding new columns to database tables, enabling a versatile way to store and manage data specific to each record.

    Show full answer Show less

    Key Features

    • Flexible Metadata Organization: Create a structured framework to group dynamic attributes into groups and organize those groups into higher-level categories.
    • Dynamic Data Capture: Capture different attributes for each record dynamically, accommodating diverse data needs without schema changes.
    • Dynamic Attribute Store Fields: Add fields specifically designed to hold dynamic attribute data as string objects within your tables.
    • API Support: Utilize global JavaScript APIs such as DynamicSchemaAPI, GlideAggregate, GlideRecord, and others tailored to support creating, querying, and managing dynamic attributes efficiently.

    Practical Use and Workflow

    ServiceNow customers can plan their metadata strategy by:

    • Defining groups of attributes relevant to their data model.
    • Organizing these groups into meaningful categories.
    • Adding dynamic attribute store fields to tables to hold the dynamic data.
    • Populating these fields programmatically using the GlideRecord setValue() method or other supported API methods.

    For example, in a Products table with diverse product types, you can define groupings of attributes for each product type (like screen type for electronics, color for clothing) and categorize them accordingly. This allows each product record to capture only relevant attributes dynamically.

    API Utilization

    The provided APIs enable customers to:

    • Access and modify dynamic attributes on records.
    • Query records using dynamic attribute fields.
    • Aggregate and group data based on dynamic attributes.
    • Set and retrieve dynamic attribute values and display values programmatically.

    This comprehensive API support ensures that customers can effectively integrate dynamic schema capabilities into their custom applications and workflows.

    Define a hierarchy of categories, groups, and attributes and enable users to select groups of attributes on a record.

    Key benefits

    • Organize and define metadata in flexible schema instead of adding new columns to a table.
    • Define a structured framework for grouping dynamic attributes.
    • Capture data dynamically using different attributes per record.

    Dynamic schema workflow

    1. Plan your metadata strategy.
    2. Create groups of attributes.
    3. Add dynamic attributes to each group.
    4. Organize your groups into categories.
    5. Add dynamic attribute store fields to your tables.
    6. Populate dynamic attribute store fields using the GlideRecord setValue() method.

    Use cases

    • Capture groups of attribute-value pairs that describe products sold in a large department store by defining a dynamic schema for your products. Store the attributes and their data in a dynamic attribute store field.

      For example, assume you have a custom Products table that stores records for different types of products like televisions, sunscreens, pillows, and shirts. You can create groups of dynamic attributes for each type of product (like screen type, UPC, color, or size). You can organize the groups into dynamic categories (like electronics, health and beauty, home goods, and clothing). Users can add records to your Products table and capture different attributes in each product record.

    • Describe a record by capturing one or more dynamic attribute-value pairs as string objects in a dynamic attribute store field. You can also capture transient attribute-value pairs on a record by adding a dynamic attribute store field to a table and populating the field with string data using the GlideRecord API.

    APIs

    Dynamic schema also provides global APIs that enable you to access and manage dynamic attributes in your tables using JavaScripts. The following lists the APIs and methods that support dynamic attributes.