GlideTransientDynamicAttribute - Global

  • Versão de lançamento: Yokohama
  • Atualizado 30 de jan. de 2025
  • 7 min. de leitura
  • A API GlideTransientDynamicAttribute fornece acesso a metadados de atributos dinâmicos transitórios.

    Esta API fornece métodos que permitem obter valores de atributos dinâmicos transitórios que são adicionados a um campo DynamicAttributeStore e não definidos na tabela Atributo dinâmico [dynamic_attribute]. Atributos dinâmicos transitórios são todos tratados como tipos de dados de cadeia de caracteres e não têm sys_id. Para obter mais detalhes sobre atributos dinâmicos, consulte Esquema dinâmico. Os mesmos métodos também estão disponíveis para atributos dinâmicos na API GlideDynamicAttribute - Global.

    Para usar esta API para criar atributos dinâmicos, você deve ter a função dynamic_schema_writer. Para ler dados dinâmicos usando esta API, você deve ter a função dynamic_schema_reader.

    GlideTransientDynamicAttribute – getGroupName()

    Obtém o valor da propriedade de nome do grupo de um objeto de atributo dinâmico transitório.

    Tabela 1. Parâmetros
    Nome Tipo Descrição
    Nenhum
    Tabela 2. Retorna
    Tipo Descrição
    Cadeia de caracteres Valor da propriedade do nome do grupo do atributo dinâmico transitório.

    Consulte também Create a dynamic attribute group.

    No exemplo a seguir, o valor do nome do grupo de objetos de atributo dinâmico transitório é exibido como um.

    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());
    }

    Saída:

    *** 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

    GlideTransientDynamicAttribute – getName()

    Obtém o valor da propriedade de nome de um objeto de atributo dinâmico transitório.

    Tabela 3. Parâmetros
    Nome Tipo Descrição
    Nenhum
    Tabela 4. Retorna
    Tipo Descrição
    Cadeia de caracteres Valor da propriedade de nome do atributo dinâmico transitório.

    No exemplo a seguir, o valor do nome do objeto de atributo dinâmico transitório é exibido como b.

    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());
    }

    Saída:

    *** 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

    GlideTransientDynamicAttribute – getPath()

    Obtém o valor da propriedade de caminho de um objeto de atributo dinâmico transitório.

    Tabela 5. Parâmetros
    Nome Tipo Descrição
    Nenhum
    Tabela 6. Retorna
    Tipo Descrição
    Cadeia de caracteres Valor do caminho do atributo dinâmico transitório.

    No exemplo a seguir, o valor do caminho do objeto de atributo dinâmico transitório é exibido como a->b.

    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());
    }

    Saída:

    *** 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

    GlideTransientDynamicAttribute – getSysId()

    Obtém o valor sys_id (indefinido) de um objeto de atributo dinâmico transitório.

    Tabela 7. Parâmetros
    Nome Tipo Descrição
    Nenhum
    Tabela 8. Retorna
    Tipo Descrição
    Cadeia de caracteres Se o objeto selecionado for um atributo dinâmico transitório, o resultado será indefinido. Caso contrário, sys_id de um atributo dinâmico.

    No exemplo a seguir, o valor do sys_id do objeto de atributo dinâmico transitório é exibido como nulo.

    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());
    }

    Saída:

    *** 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

    GlideTransientDynamicAttribute – getType()

    Obtém o valor da propriedade de tipo de um objeto de atributo dinâmico transitório.

    Tabela 9. Parâmetros
    Nome Tipo Descrição
    Nenhum
    Tabela 10. Retorna
    Tipo Descrição
    Cadeia de caracteres Valor do tipo de dados do atributo dinâmico transitório. O tipo de dados para atributos dinâmicos transitórios é sempre cadeia de caracteres.

    No exemplo a seguir, o valor do tipo de objeto de atributo dinâmico transitório é exibido como cadeia de caracteres.

    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());
    }

    Saída:

    *** 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

    GlideTransientDynamicAttribute - isTransient()

    Retorna se um objeto é um atributo dinâmico transitório.

    Tabela 11. Parâmetros
    Nome Tipo Descrição
    Nenhum
    Tabela 12. Retorna
    Tipo Descrição
    Booliano Sinalizador que indica se um atributo dinâmico é transitório.
    Valores válidos:
    • verdadeiro: o atributo dinâmico é transitório. Os atributos dinâmicos são definidos na tabela Atributo dinâmico [dynamic-attribute] com um tipo de dados e um sys-id.
    • falso: o atributo dinâmico não é transitório. Atributos dinâmicos transitórios são atributos dinâmicos que foram adicionados a um campo DynamicAttributeStore sem uma definição na tabela Atributo dinâmico [dynamic_attribute]. Atributos dinâmicos transitórios são tratados como cadeias de caracteres e não têm sys_id.
    Nota:
    A tabela Atributo dinâmico [dynamic_attribute] pode ser acessada navegando até Tudo > Esquema dinâmico > Grupos de atributos dinâmicos, selecionando um grupo e selecionando a guia Atributos dinâmicos.

    No exemplo a seguir, o método isTransient() retorna verdadeiro para o objeto transitório.

    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());
    }

    Saída:

    *** 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