{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":39092,"path":"platform-administration/name-value-pair-scripting.md","title":"Name-value pairs field type","bundle":null,"doc_type":null,"release":"australia","body":"\n# Name-value pairs field type\n\nYou can access the values stored in a name-value pairs field in scripts using the name.\n\n## Sample script\n\nThe following example demonstrates how to add mappings to a name-value pairs field, and how to query existing values using the name.\n\n```\n// Script example demonstrating setting and getting values\nvar gr = new GlideRecord('u_nv_table');\ngr.initialize();\n\ngr.nv_field.name1 = \"value1\"; //add a name-value Pair mapping with the name \"name1\" and value \"value1\"\ngr.nv_field.name2 = \"value2\"; //add another name-value Pair mapping with the name \"name2\" and value \"value2\"\n\n// Access by dot notation\ngs.print(\"name1 = \" + gr.nv_field.name1); // Expected output: name1 = value1\n\n// Iterate over each property and print name and value\nfor(var name in gr.nv_field) {\n    gs.print(name + \" = \" + gr.nv_field[name]);\n}\n\ngs.print(gr.nv_field); // Expected output: {\"name1\":\"value1\",\"name2\":\"value2\"}\n```\n\n"}}