GlideDynamicAttribute - Global

  • Release version: Yokohama
  • Updated January 30, 2025
  • 7 minutes to read
  • The GlideDynamicAttribute API provides access to dynamic attribute metadata.

    This API provides methods that enable you to get dynamic schema values defined in the Dynamic Attribute [dynamic_attribute] table. Dynamic attributes have a defined data type and a sys_id. For more details on dynamic attributes, see Dynamic schema. The same methods are also available for transient dynamic attributes in the GlideTransientDynamicAttribute - Global API.

    To use this API to create dynamic attributes you must have the dynamic_schema_writer role. To read dynamic data using this API you must have the dynamic_schema_reader role.

    GlideDynamicAttribute - getGroupName()

    Gets the value of the group name property of a dynamic attribute object.

    Table 1. Parameters
    Name Type Description
    None
    Table 2. Returns
    Type Description
    String Value of the dynamic attribute's group name property.

    See also Create a dynamic attribute group.

    In the following example, the value of the dynamic attribute object group name is displayed as a.

    var das = new GlideDynamicAttributeStore();
    das.setDynamicAttributeValue('a->b', 5);    // transient (adding here)
    das.setDynamicAttributeValue('a->c', 10);   // defined in dynamic_attribute table
    
    var attributes = das.getDynamicAttributes();
    gs.info(attributes);
    
    for (var i = 0; i < attributes.length; i++) {
        var attr = attributes[i];
    	
        gs.info("");
        gs.info("[" + i + "].getPath()      = " + attr.getPath());
        gs.info("[" + i + "].getName()      = " + attr.getName());
        gs.info("[" + i + "].getGroupName() = " + attr.getGroupName());
        gs.info("[" + i + "].getSysId()     = " + attr.getSysId());
        gs.info("[" + i + "].isTransient()  = " + attr.isTransient());
        gs.info("[" + i + "].getType()      = " + attr.getType());
    }

    Output:

    *** Script: a->c,a->b
    *** Script: 
    *** Script: [0].getPath()      = a->c
    *** Script: [0].getName()      = c
    *** Script: [0].getGroupName() = a
    *** Script: [0].getSysId()     = 8bc411a94fc01210b8ddc0e552ce0b3c
    *** Script: [0].isTransient()  = false
    *** Script: [0].getType()      = integer
    *** Script: 
    *** Script: [1].getPath()      = a->b
    *** Script: [1].getName()      = b
    *** Script: [1].getGroupName() = a
    *** Script: [1].getSysId()     = undefined
    *** Script: [1].isTransient()  = true
    *** Script: [1].getType()      = string

    GlideDynamicAttribute - getName()

    Gets the value of the name property of a dynamic attribute object.

    Table 3. Parameters
    Name Type Description
    None
    Table 4. Returns
    Type Description
    String Value of the dynamic attribute's name property.

    In the following example, the value of the dynamic attribute object name is displayed as c.

    var das = new GlideDynamicAttributeStore();
    das.setDynamicAttributeValue('a->b', 5);    // transient (adding here)
    das.setDynamicAttributeValue('a->c', 10);   // defined in dynamic_attribute table
    
    var attributes = das.getDynamicAttributes();
    gs.info(attributes);
    
    for (var i = 0; i < attributes.length; i++) {
        var attr = attributes[i];
    	
        gs.info("");
        gs.info("[" + i + "].getPath()      = " + attr.getPath());
        gs.info("[" + i + "].getName()      = " + attr.getName());
        gs.info("[" + i + "].getGroupName() = " + attr.getGroupName());
        gs.info("[" + i + "].getSysId()     = " + attr.getSysId());
        gs.info("[" + i + "].isTransient()  = " + attr.isTransient());
        gs.info("[" + i + "].getType()      = " + attr.getType());
    }

    Output:

    *** Script: a->c,a->b
    *** Script: 
    *** Script: [0].getPath()      = a->c
    *** Script: [0].getName()      = c
    *** Script: [0].getGroupName() = a
    *** Script: [0].getSysId()     = 8bc411a94fc01210b8ddc0e552ce0b3c
    *** Script: [0].isTransient()  = false
    *** Script: [0].getType()      = integer
    *** Script: 
    *** Script: [1].getPath()      = a->b
    *** Script: [1].getName()      = b
    *** Script: [1].getGroupName() = a
    *** Script: [1].getSysId()     = undefined
    *** Script: [1].isTransient()  = true
    *** Script: [1].getType()      = string

    GlideDynamicAttribute - getPath()

    Gets the value of the path property of a dynamic attribute object.

    Table 5. Parameters
    Name Type Description
    None
    Table 6. Returns
    Type Description
    String Value of the dynamic attribute's path.

    In the following example, the value of the dynamic attribute object path is displayed as a->c.

    var das = new GlideDynamicAttributeStore();
    das.setDynamicAttributeValue('a->b', 5);    // transient (adding here)
    das.setDynamicAttributeValue('a->c', 10);   // defined in dynamic_attribute table
    
    var attributes = das.getDynamicAttributes();
    gs.info(attributes);
    
    for (var i = 0; i < attributes.length; i++) {
        var attr = attributes[i];
    	
        gs.info("");
        gs.info("[" + i + "].getPath()      = " + attr.getPath());
        gs.info("[" + i + "].getName()      = " + attr.getName());
        gs.info("[" + i + "].getGroupName() = " + attr.getGroupName());
        gs.info("[" + i + "].getSysId()     = " + attr.getSysId());
        gs.info("[" + i + "].isTransient()  = " + attr.isTransient());
        gs.info("[" + i + "].getType()      = " + attr.getType());
    }

    Output:

    *** Script: a->c,a->b
    *** Script: 
    *** Script: [0].getPath()      = a->c
    *** Script: [0].getName()      = c
    *** Script: [0].getGroupName() = a
    *** Script: [0].getSysId()     = 8bc411a94fc01210b8ddc0e552ce0b3c
    *** Script: [0].isTransient()  = false
    *** Script: [0].getType()      = integer
    *** Script: 
    *** Script: [1].getPath()      = a->b
    *** Script: [1].getName()      = b
    *** Script: [1].getGroupName() = a
    *** Script: [1].getSysId()     = undefined
    *** Script: [1].isTransient()  = true
    *** Script: [1].getType()      = string

    GlideDynamicAttribute - getSysId()

    Gets the sys_id of a dynamic attribute object.

    Table 7. Parameters
    Name Type Description
    None
    Table 8. Returns
    Type Description
    String Value of the dynamic attribute's sys_id.

    In the following example, the value of the dynamic attribute object's sys_id is displayed as 8bc411a94fc01210b8ddc0e552ce0b3c.

    var das = new GlideDynamicAttributeStore();
    das.setDynamicAttributeValue('a->b', 5);    // transient (adding here)
    das.setDynamicAttributeValue('a->c', 10);   // defined in dynamic_attribute table
    
    var attributes = das.getDynamicAttributes();
    gs.info(attributes);
    
    for (var i = 0; i < attributes.length; i++) {
        var attr = attributes[i];
    	
        gs.info("");
        gs.info("[" + i + "].getPath()      = " + attr.getPath());
        gs.info("[" + i + "].getName()      = " + attr.getName());
        gs.info("[" + i + "].getGroupName() = " + attr.getGroupName());
        gs.info("[" + i + "].getSysId()     = " + attr.getSysId());
        gs.info("[" + i + "].isTransient()  = " + attr.isTransient());
        gs.info("[" + i + "].getType()      = " + attr.getType());
    }

    Output:

    *** Script: a->c,a->b
    *** Script: 
    *** Script: [0].getPath()      = a->c
    *** Script: [0].getName()      = c
    *** Script: [0].getGroupName() = a
    *** Script: [0].getSysId()     = 8bc411a94fc01210b8ddc0e552ce0b3c
    *** Script: [0].isTransient()  = false
    *** Script: [0].getType()      = integer
    *** Script: 
    *** Script: [1].getPath()      = a->b
    *** Script: [1].getName()      = b
    *** Script: [1].getGroupName() = a
    *** Script: [1].getSysId()     = undefined
    *** Script: [1].isTransient()  = true
    *** Script: [1].getType()      = string

    GlideDynamicAttribute - getType()

    Gets the value of the type property of a dynamic attribute object.

    Table 9. Parameters
    Name Type Description
    None
    Table 10. Returns
    Type Description
    String Value of the dynamic attribute's data type.

    In the following example, the value of the dynamic attribute object type is displayed as integer.

    var das = new GlideDynamicAttributeStore();
    das.setDynamicAttributeValue('a->b', 5);    // transient (adding here)
    das.setDynamicAttributeValue('a->c', 10);   // defined in dynamic_attribute table
    
    var attributes = das.getDynamicAttributes();
    gs.info(attributes);
    
    for (var i = 0; i < attributes.length; i++) {
        var attr = attributes[i];
    	
        gs.info("");
        gs.info("[" + i + "].getPath()      = " + attr.getPath());
        gs.info("[" + i + "].getName()      = " + attr.getName());
        gs.info("[" + i + "].getGroupName() = " + attr.getGroupName());
        gs.info("[" + i + "].getSysId()     = " + attr.getSysId());
        gs.info("[" + i + "].isTransient()  = " + attr.isTransient());
        gs.info("[" + i + "].getType()      = " + attr.getType());
    }

    Output:

    *** Script: a->c,a->b
    *** Script: 
    *** Script: [0].getPath()      = a->c
    *** Script: [0].getName()      = c
    *** Script: [0].getGroupName() = a
    *** Script: [0].getSysId()     = 8bc411a94fc01210b8ddc0e552ce0b3c
    *** Script: [0].isTransient()  = false
    *** Script: [0].getType()      = integer
    *** Script: 
    *** Script: [1].getPath()      = a->b
    *** Script: [1].getName()      = b
    *** Script: [1].getGroupName() = a
    *** Script: [1].getSysId()     = undefined
    *** Script: [1].isTransient()  = true
    *** Script: [1].getType()      = string

    GlideDynamicAttribute - isTransient()

    Returns whether an object is a transient dynamic attribute.

    Table 11. Parameters
    Name Type Description
    None
    Table 12. Returns
    Type Description
    Boolean Flag that indicates if a dynamic attribute is transient.
    Valid values:
    • true: The dynamic attribute is transient. Dynamic attributes are defined in the Dynamic Attribute [dynamic_attribute] table with a data type and a sys_id.
    • false: The dynamic attribute is not transient. Transient dynamic attributes are dynamic attributes that have been added to a DynamicAttributeStore field without a definition in the Dynamic Attribute [dynamic_attribute] table. Transient dynamic attributes are handled as strings and have no sys_id.
    Note:
    The Dynamic Attribute [dynamic_attribute] table is accessible by navigating to All > Dynamic Schema > Dynamic Attribute Groups, selecting a group, and selecting the Dynamic Attributes tab.

    In the following example, the isTransient() method returns false for the non-transient object.

    var das = new GlideDynamicAttributeStore();
    das.setDynamicAttributeValue('a->b', 5);    // transient (adding here)
    das.setDynamicAttributeValue('a->c', 10);   // defined in dynamic_attribute table
    
    var attributes = das.getDynamicAttributes();
    gs.info(attributes);
    
    for (var i = 0; i < attributes.length; i++) {
        var attr = attributes[i];
    	
        gs.info("");
        gs.info("[" + i + "].getPath()      = " + attr.getPath());
        gs.info("[" + i + "].getName()      = " + attr.getName());
        gs.info("[" + i + "].getGroupName() = " + attr.getGroupName());
        gs.info("[" + i + "].getSysId()     = " + attr.getSysId());
        gs.info("[" + i + "].isTransient()  = " + attr.isTransient());
        gs.info("[" + i + "].getType()      = " + attr.getType());
    }

    Output:

    *** Script: a->c,a->b
    *** Script: 
    *** Script: [0].getPath()      = a->c
    *** Script: [0].getName()      = c
    *** Script: [0].getGroupName() = a
    *** Script: [0].getSysId()     = 8bc411a94fc01210b8ddc0e552ce0b3c
    *** Script: [0].isTransient()  = false
    *** Script: [0].getType()      = integer
    *** Script: 
    *** Script: [1].getPath()      = a->b
    *** Script: [1].getName()      = b
    *** Script: [1].getGroupName() = a
    *** Script: [1].getSysId()     = undefined
    *** Script: [1].isTransient()  = true
    *** Script: [1].getType()      = string