Name-value pairs field type

reference brazil Updated Nov 6, 2026 1 min read name-value-pair-scripting.md
Raw file servicenow.com

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.

JavaScript
// Script example demonstrating setting and getting valuesvar 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 notationgs.print("name1 = " + gr.nv_field.name1); // Expected output: name1 = value1
// Iterate over each property and print name and valuefor(var name in gr.nv_field) {    gs.print(name + " = " + gr.nv_field[name]);}
gs.print(gr.nv_field); // Expected output: {"name1":"value1","name2":"value2"}
Search documentation
Search document titles and file paths on the brazil branch