Dynamic Schema
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
- Plan your metadata strategy.
- Create groups of attributes.
- Add dynamic attributes to each group.
- Organize your groups into categories.
- Add dynamic attribute store fields to your tables.
- 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
- DynamicSchemaAPI - Global
- GlideAggregate - Global
Only the following GlideAggregate methods support the usage of dynamic attributes:
- GlideAggregate - addAggregate(String agg, String name)
- GlideAggregate - addHaving(String aggName, String fieldName, String operator, String value)
- GlideAggregate - getValue(String name)
- GlideAggregate - groupBy(String name)
- GlideAggregate - orderBy(String name)
- GlideAggregate - orderByAggregate(String agg, String fieldName)
- GlideDynamicAttributeStore - Global
- GlideElementDynamicAttributeStore - Global
- GlideRecord - Global
Only the following GlideRecord methods support dynamic attributes:
- GlideRecord - addQuery(String name, Object operator, Object value)
- GlideRecord - getDisplayValue(String name)
- GlideRecord - getDynamicAttribute(String fullPath)
- GlideRecord - getDynamicAttribute(String dynamicAttributeField, String groupAttrPath)
- GlideRecord - getDynamicAttributeDisplayValue(String fullPath)
- GlideRecord - getDynamicAttributeDisplayValue(String dynamicAttributeField, String groupAttrPath)
- GlideRecord - getDynamicAttributeValue(String fullPath)
- GlideRecord - getDynamicAttributeValue(String dynamicAttributeField, String groupAttrPath)
- GlideRecord - getValue(String fieldName)
- GlideRecord - orderBy(String fieldName)
- GlideRecord - orderByDesc(String fieldName)
- GlideRecord - setDisplayValue(String name, Object value)
- GlideRecord - setDynamicAttributeDisplayValue(String fullPath, Object value)
- GlideRecord - setDynamicAttributeDisplayValue(String dynamicAttributeField, String groupAttrPath, Object value)
- GlideRecord - setDynamicAttributeValue(String fullPath, Object value)
- GlideRecord - setDynamicAttributeValue(String dynamicAttributeField, String groupAttrPath, Object value)
- GlideRecord - setDynamicAttributeValues(String dynamicAttributeField, GlideDynamicAttributeStore values)
- GlideRecord - setValue(String name, Object value)