{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":38116,"path":"platform-administration/add-transient-attributes.md","title":"Add transient attributes to a record","bundle":null,"doc_type":null,"release":"australia","body":"\n# Add transient attributes to a record\n\nStore transient attributes and their values on a record.\n\n## Before you begin\n\nRole required: none\n\nTo add attributes to a dynamic attribute store field, you must have write access to the table where the store field is located.\n\n## About this task\n\nAfter creating a dynamic attribute store field on a table, you can immediately start adding attributes to a record without having to define a dynamic attribute record for each attribute. Attributes without a definition are considered transient and are treated as having values of type string when used in scripts and queries.\n\n## Procedure\n\n1.  Navigate to the table that holds your dynamic attribute store field.\n\n2.  Create a record by selecting **New**.\n\n3.  Add one or more attributes directly on the form using JSON or via the API.\n\n<table id=\"choicetable_hbk_hpf_yfc\"><thead><tr><th align=\"left\" id=\"d87564e78\">\n\nOption\n\n</th><th align=\"left\" id=\"d87564e81\">\n\nDescription\n\n</th></tr></thead><tbody><tr><td id=\"d87564e87\">\n\n**Enter JSON on the form**\n\n</td><td>\n\n1.  In the category reference field, select the dynamic category that contains the dynamic attributes that you want to use.\n2.  Enter one or more attributes and their values. For example:\n\n    ```\n\"screen_resolution\":\"2160p\",\"screen_size\":\"75\",\"screen_type\":\"OLED\"\n    ```\n\n</td></tr><tr><td id=\"d87564e107\">\n\n**Call setValue\\(\\)**\n\n</td><td>\n\nCall setValue\\(\\) in the GlideRecord API and send data to the dynamic attribute store field.For example:```javascript\nvar gr = new GlideRecord(‘products’);\ngr.setValue(‘television_specs->screen_resolution', '2160p');\ngr.setValue('television_specs->screen_size', '75');\ngr.setValue('television_specs->screen_type', 'OLED');\ngr.insert();\n```\n\n</td></tr></tbody>\n</table>\n## Result\n\nOne or more transient attributes are added to the store field, with each value stored as a string. Users can query or search for records using the values captured in the dynamic attribute store field. For example:\n\n```javascript\nvar gr = new GlideRecord(‘products’);\ngr.addQuery(‘television_specs->screen_type', ‘OLED’);\ngr.query();\n```\n\n## What to do next\n\nDecide whether to create formal definitions for each attribute. Providing a formal definition makes the attribute non-transient and allows you to modify its behavior. To provide this definition, navigate to the dynamic namespace record the store field is configured with and create a dynamic attribute record using the name of the attribute you wish to modify. See [Create a dynamic attribute](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/platform-administration/add-dynamic-attributes.md).\n\nNote that modifying the definition of an attribute doesn't modify any data stored for that attribute. Rather, it simply modifies how the system interacts with that data. For example, attributes defined as strings sort differently than when defined as integers.\n\nSorting age values as strings:\n\n```\n11\n19\n2\n25\n3\n```\n\nSorting age values as integers:\n\n```\n2\n3\n11\n19\n25\n```\n\nAny saved data that might be invalid for its defined type is treated as having a nil value appropriate for the type. For example, storing a value of \"dog\" for an attribute, and then formally defining it as an integer will effectively use 0 in all queries and calculations that attribute is used in, even though the data stored for the attribute remains as “dog\".\n\n"}}