Name-value pairs field type

  • Rversion finale: Australia
  • Mis à jour 13 mars 2026
  • 1 minute de lecture
  • You can access the values stored in a name-value pairs field in scripts using the name.

    Sample script

    The following example demonstrates how to add mappings to a name-value pairs field, and how to query existing values using the name.
    // Script example demonstrating setting and getting values
    var gr = new GlideRecord('u_nv_table');
    gr.initialize();
    
    gr.nv_field.name1 = "value1"; //add a name-value Pair mapping with the name "name1" and value "value1"
    gr.nv_field.name2 = "value2"; //add another name-value Pair mapping with the name "name2" and value "value2"
    
    // Access by dot notation
    gs.print("name1 = " + gr.nv_field.name1); // Expected output: name1 = value1
    
    // Iterate over each property and print name and value
    for(var name in gr.nv_field) {
        gs.print(name + " = " + gr.nv_field[name]);
    }
    
    gs.print(gr.nv_field); // Expected output: {"name1":"value1","name2":"value2"}