{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":1022,"path":"api-reference/server-api-reference/c_GlideRecordAPI.md","title":"GlideRecord - Global","bundle":null,"doc_type":null,"release":"australia","body":"\n# GlideRecord- Global\n\nThe GlideRecord API is used for database operations.\n\nThe GlideRecord API is the primary means of interfacing with the database on the server-side code. A GlideRecord is an object that contains records from a single table. Use the API to instantiate a GlideRecord object and add query parameters, filters, limits, and ordering.\n\nTo use this API to create dynamic attributes you must have the dynamic\\_schema\\_writer role. To read dynamic data using this API you must have the dynamic\\_schema\\_reader role.\n\nFor information on a class that performs the same functions as GlideRecord and enforces ACLs, see [Using GlideRecordSecure](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/scripts/p_GlideServerAPIs.md).\n\nSee also [Dynamic Schema](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/dynamic-schema.md).\n\nSee the [GlideRecord](https://developer.servicenow.com/dev.do#!/learn/courses/utah/app_store_learnv2_scripting_utah_scripting_in_servicenow/app_store_learnv2_scripting_utah_server_side_scripting/app_store_learnv2_scripting_utah_gliderecord) article for details on building and running queries.\n\nFor information about GlideRecordSecure, which is a class inherited from GlideRecord that performs the same functions as GlideRecord and also enforces ACLs, see the [GlideServer APIs](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/scripts/p_GlideServerAPIs.md).\n\nAlways test queries on a sub-production instance prior to deploying them on a production instance. An incorrectly constructed encoded query, such as including an invalid field name, produces an invalid query. When the invalid query is run, the invalid part of the query condition is dropped, and the results are based on the valid part of the query, which may return all records from the table. Using an insert\\(\\), update\\(\\), deleteRecord\\(\\), or deleteMultiple\\(\\) method on bad query results can result in data loss.\n\nYou can set the **glide.invalid\\_query.returns\\_no\\_rows** system property to true to have queries with invalid encoded queries return no records. In some cases, the query may still return records in API results even when **glide.invalid\\_query.returns\\_no\\_rows** is set to true. This happens in queries where an invalid query term is used with a WHERE operator. In such queries, the WHERE operator ignores the invalid term\\(s\\) but still interprets and returns the rest of the query statement. For more information about this system property and its functionality, see [Available system properties](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/r_AvailableSystemProperties.md).\n\n## Retrieve values from records\n\nIn most cases, don’t use dot-walking to get values from a record. Dot-walking retrieves the entire object instead of the field value. Retrieving the object uses more storage and might cause undesirable results when used in arrays or in Service Portal.\n\nInstead of retrieving the entire object, you can use one of the following methods to copy the field values:\n\n-   [getValue\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md)\n-   [getDisplayValue\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md)\n\nIf dot-walking through a GlideElement object is necessary, use the toString\\(\\) method to retrieve values. For example, you might need the current caller's manager sys\\_id to set another reference field. The following example shows how to get the string value instead of the entire object:\n\n```\nvar mgr = current.caller_id.manager.toString();\n```\n\n## Dynamic attributes\n\nThere are methods in this API that have the same functionality as dynamic schema methods in the [GlideDynamicAttributeStore - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideDynamicAttStoreAPI.md) API. Use the dynamic attribute methods in this API to perform actions on a specified GlideRecord. Use the methods in the GlideDynamicAttributeStore API if you want to set the same group of dynamic attributes on multiple records. Using this API, you can stage a GlideDynamicAttributeStore object with the desired attributes and then copy that object to multiple GlideRecords using the various setDynamicAttributeValues\\(\\) methods.\n\nSee also:\n\n-   [GlideAggregate](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideAggregateAPI.md)\n-   [GlideElement](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideElementAPI.md)\n-   [GlideQuery](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideQueryGlobalAPI.md)\n\n**Parent Topic:**[Server API reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/api-server.md)\n\n## GlideRecord - GlideRecord\\(String tableName\\)\n\nCreates an instance of the GlideRecord class for the specified table.\n\n|Name|Type|Description|\n|----|----|-----------|\n|tableName|String|Table to use.|\n\n```\nvar now_GR = new GlideRecord('incident');\n```\n\n## GlideRecord - addActiveQuery\\(\\)\n\nAdds a filter to return active records.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|GlideQueryCondition|Filter to return active records.|\n\n```\nvar inc = new GlideRecord('incident');\ninc.addActiveQuery();\ninc.query();\n```\n\n### Scoped equivalent\n\nTo use the addActiveQuery\\(\\) method in a scoped application, use the corresponding scoped method: [addActiveQuery\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - addDomainQuery\\(Object glideRecord\\)\n\nChanges the domain used for the query from the user's domain to the domain of the provided GlideRecord.\n\nAlways test queries on a sub-production instance prior to deploying them on a production instance. An incorrectly constructed encoded query, such as including an invalid field name, produces an invalid query. When the invalid query is run, the invalid part of the query condition is dropped, and the results are based on the valid part of the query, which may return all records from the table. Using an insert\\(\\), update\\(\\), deleteRecord\\(\\), or deleteMultiple\\(\\) method on bad query results can result in data loss.\n\nYou can set the **glide.invalid\\_query.returns\\_no\\_rows** system property to true to have queries with invalid encoded queries return no records. In some cases, the query may still return records in API results even when **glide.invalid\\_query.returns\\_no\\_rows** is set to true. This happens in queries where an invalid query term is used with a WHERE operator. In such queries, the WHERE operator ignores the invalid term\\(s\\) but still interprets and returns the rest of the query statement. For more information about this system property and its functionality, see [Available system properties](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/r_AvailableSystemProperties.md).\n\nThis function requires the Domain Support - Domain Extensions Installer \\(com.glide.domain.msp\\_extensions.installer\\) plugin.\n\n|Name|Type|Description|\n|----|----|-----------|\n|glideRecord|Object|GlideRecord from which to obtain the domain.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n```\n//This example requires the Domain plugin be active, the Group table is the specified \n//Domain table, and the ITIL user is in the Database Atlanta domain\n//From any domain (using queryNoDomain()) look up the incidents that an ITIL user can only see \n//who is in the Database Atlanta domain, should expect all incidents with the global or the\n//Database Atlanta domain specified.\nvar domain = new GlideRecord('sys_user');\ndomain.addQuery('user_name', 'itil');\ndomain.queryNoDomain();\nif (domain.next()) {\n    var domainQuery = new GlideRecord('incident');\n    domainQuery.addQuery('active', true);\n    domainQuery.addDomainQuery(domain);\n    domainQuery.query();\n    gs.print('Number of Incidents for ITIL user: ' + domainQuery.getRowCount());\n    while (domainQuery.next())\n        gs.print(domainQuery.number);\n}\n```\n\n### Scoped equivalent\n\nThis method is not available in scoped applications.\n\n## GlideRecord - addEncodedQuery\\(String query, Boolean enforceFieldACL\\)\n\nAdds an encoded query to other queries that may have been set.\n\nAlways test queries on a sub-production instance prior to deploying them on a production instance. An incorrectly constructed encoded query, such as including an invalid field name, produces an invalid query. When the invalid query is run, the invalid part of the query condition is dropped, and the results are based on the valid part of the query, which may return all records from the table. Using an insert\\(\\), update\\(\\), deleteRecord\\(\\), or deleteMultiple\\(\\) method on bad query results can result in data loss.\n\nYou can set the **glide.invalid\\_query.returns\\_no\\_rows** system property to true to have queries with invalid encoded queries return no records. In some cases, the query may still return records in API results even when **glide.invalid\\_query.returns\\_no\\_rows** is set to true. This happens in queries where an invalid query term is used with a WHERE operator. In such queries, the WHERE operator ignores the invalid term\\(s\\) but still interprets and returns the rest of the query statement. For more information about this system property and its functionality, see [Available system properties](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/r_AvailableSystemProperties.md).\n\n**Note:** To enforce query access based on the user, use[addUserEncodedQuery\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md).\n\n<table id=\"table_j3p_mlp_dt\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nquery\n\n</td><td>\n\nString\n\n</td><td>\n\nAn [encoded query string](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-user-interface/c_EncodedQueryStrings.md).\n\n</td></tr><tr><td>\n\nenforceFieldACL\n\n</td><td>\n\nBoolean\n\n</td><td>\n\nOptional. Flag that indicates whether to enforce field ACL \\(Access Control List\\) rules.Valid values:\n\n-   true: Enforce field ACLs.\n-   false: Don't enforce field ACLs.\n\nDefault: false\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|void| |\n\n```\nvar queryString = \"priority=1^ORpriority=2\";\n var now_GR = new GlideRecord('incident');\n \n now_GR.addEncodedQuery(queryString);\n now_GR.query();\n while (now_GR.next()) {\n gs.addInfoMessage(now_GR.number);\n }\n```\n\n### Scoped equivalent\n\nTo use the addEncodedQuery\\(\\) method in a scoped application, use the corresponding scoped method: [addEncodedQuery\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - addExtraField\\(String dotWalkedField\\)\n\nQueries one or more dot-walked fields from a form or script in a single request.\n\nThe addExtraField\\(\\) method allows you to query dot-walked fields in a single database request, rather than perform multiple queries per dot-walked element in a form or script \\(which requires multiple round trips to the database\\).\n\n<table id=\"table_ctk_qcx_hzb\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\ndotWalkedField\n\n</td><td>\n\nString\n\n</td><td>\n\nThe dot-walked field name. Levels of field names are separated by dots \\(periods\\). For example, enter the value `Caller.Company` if you want to query the **Company** &gt; **Caller** condition in the Incident \\[incident\\] table.The format of **dotWalkedField** follows the left-to-right order of fields in a dotwalked form or script.\n\n</td></tr></tbody>\n</table><table id=\"table_dtk_qcx_hzb\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nNone\n\n</td><td>\n\n**Note:** The addExtraField\\(\\) method does not impact output results; the output is always the same regardless if you use this method in your script.\n\n</td></tr></tbody>\n</table>The following example shows how to query the contact name field of cmn\\_location \\(referenced from the “location” reference field in a cmdb\\_ci field\\).\n\n**Note:** The dotWalkedField value in this example, `cmdb_ci.location.contact.name`, looks like “cmdb\\_ci fields” =&gt; “cmn\\_location fields” =&gt; “sys\\_user fields” in the ServiceNow® UI when selecting fields in a list.\n\n```\nvar gliderecord = new GlideRecord(\"incident\");\ngliderecord.addQuery(\"number\", \"INC0041457\");\ngliderecord.addExtraField(\"cmdb_ci.location.contact.name\");\ngliderecord.query();\ngliderecord.next();\ngs.print(gliderecord.cmdb_ci.location.contact.name);\n```\n\nThe output is the same as `gs.print(gr.cmdb_ci.location.contact.name)` without using addExtraField\\(\\). The addExtraField\\(\\) method optimizes the querying of the dot-walked fields. Example output:\n\n```\nAbel Tuter\n```\n\n## GlideRecord - addFunction\\(Object function\\)\n\nApplies a pre-defined GlideDBFunctionBuilder object to a record.\n\nUse the GlideDBFunctionBuilder scoped class to define a function. After the function is defined, use the addFunction\\(Object function\\) method to apply the function to a record.\n\n|Name|Type|Description|\n|----|----|-----------|\n|function|Object|A GlideDBFunctionBuilder or GlideDBCaseStatementBuilder object that defines a SQL operation.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n```\nvar functionBuilder = new GlideDBFunctionBuilder();\nvar myAddingFunction = functionBuilder.add();\nmyAddingFunction = functionBuilder.field('order');\nmyAddingFunction = functionBuilder.field('priority');\nmyAddingFunction = functionBuilder.build();\n\nvar now_GR = new GlideRecord('incident');\nnow_GR.addFunction(myAddingFunction);\nnow_GR.addQuery(myAddingFunction, '<', 5);\nnow_GR.query();\nwhile(now_GR.next())\ngs.log(now_GR.getValue(myAddingFunction));\n\n```\n\nOutput:\n\n```\n*** Script: 1\n*** Script: 4\n*** Script: 3\n*** Script: 1\n*** Script: 1\n*** Script: 2\n*** Script: 1\n*** Script: 1\n```\n\n## GlideRecord - addInactiveQuery\\(\\)\n\nAdds a filter to return inactive records. Inactive records have the active flag set to false.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|GlideQueryCondition|Records where the active flag is false.|\n\n```\nvar inc = new GlideRecord('incident');\ninc.addInactiveQuery();\ninc.query();\n```\n\n### Scoped equivalent\n\nIn scoped applications use the scoped method [addQuery\\(\"active\",\"false\"\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - addJoinQuery\\(String table\\)\n\nAdds a filter to return records based on a relationship in a related table.\n\nFor example, find all the users that are in the database group \\(users via sys\\_user\\_grmember table\\). Another example would be find all problems that have an assigned incident \\(problems via the incident.problem\\_id relationship\\).\n\nThis is not a true database join; rather, addJoinQuery\\(\\) adds a subquery. So, while the result set is limited based on the join, the only fields that you have access to are those on the base table \\(those which are in the table with which the GlideRecord was initialized\\).\n\nAlways test queries on a sub-production instance prior to deploying them on a production instance. An incorrectly constructed encoded query, such as including an invalid field name, produces an invalid query. When the invalid query is run, the invalid part of the query condition is dropped, and the results are based on the valid part of the query, which may return all records from the table. Using an insert\\(\\), update\\(\\), deleteRecord\\(\\), or deleteMultiple\\(\\) method on bad query results can result in data loss.\n\nYou can set the **glide.invalid\\_query.returns\\_no\\_rows** system property to true to have queries with invalid encoded queries return no records. In some cases, the query may still return records in API results even when **glide.invalid\\_query.returns\\_no\\_rows** is set to true. This happens in queries where an invalid query term is used with a WHERE operator. In such queries, the WHERE operator ignores the invalid term\\(s\\) but still interprets and returns the rest of the query statement. For more information about this system property and its functionality, see [Available system properties](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/r_AvailableSystemProperties.md).\n\n|Name|Type|Description|\n|----|----|-----------|\n|table|String|Table name|\n\n|Type|Description|\n|----|-----------|\n|GlideQueryCondition|Records where the relationships match.|\n\nFind problems that have an incident attached. This example returns problems that have associated incidents. However, it won't pull values from the incidents that are returned as a part of the query.\n\n```\nvar prob = new GlideRecord('problem');\nprob.addJoinQuery('incident');\nprob.query();\n```\n\nFind active=false problems with associated incidents.\n\n```\n// Look for Problem records\nvar now_GR = new GlideRecord('problem');\n \n// That have associated Incident records\nvar grSQ = now_GR.addJoinQuery('incident');\n \n// Where the Problem records are \"active=false\"\nnow_GR.addQuery('active', 'false');\n \n// And the Incident records are \"active=true\"\ngrSQ.addCondition('active', 'true');\n \n// Query\nnow_GR.query();\n \n// Iterate and print results\nwhile (now_GR.next()) {\n    gs.print(now_GR.getValue('number'));\n}\n```\n\n### Scoped equivalent\n\nTo use the addJoinQuery\\(\\) method in a scoped application, use the corresponding scoped method: [addJoinQuery\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - addJoinQuery\\(String table, String primaryField\\)\n\nAdds a filter to return records based on a relationship in a related table.\n\nFor example, find all the users that are in the database group \\(users via sys\\_user\\_grmember table\\). Another example would be find all problems that have an assigned incident \\(problems via the incident.problem\\_id relationship\\).\n\nThis is not a true database join; rather, addJoinQuery\\(\\) adds a subquery. So, while the result set is limited based on the join, the only fields that you have access to are those on the base table \\(those which are in the table with which the GlideRecord was initialized\\).\n\nAlways test queries on a sub-production instance prior to deploying them on a production instance. An incorrectly constructed encoded query, such as including an invalid field name, produces an invalid query. When the invalid query is run, the invalid part of the query condition is dropped, and the results are based on the valid part of the query, which may return all records from the table. Using an insert\\(\\), update\\(\\), deleteRecord\\(\\), or deleteMultiple\\(\\) method on bad query results can result in data loss.\n\nYou can set the **glide.invalid\\_query.returns\\_no\\_rows** system property to true to have queries with invalid encoded queries return no records. In some cases, the query may still return records in API results even when **glide.invalid\\_query.returns\\_no\\_rows** is set to true. This happens in queries where an invalid query term is used with a WHERE operator. In such queries, the WHERE operator ignores the invalid term\\(s\\) but still interprets and returns the rest of the query statement. For more information about this system property and its functionality, see [Available system properties](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/r_AvailableSystemProperties.md).\n\n|Name|Type|Description|\n|----|----|-----------|\n|table|String|Table name|\n|primaryField|String|If other than sys\\_id, the primary field.|\n\n|Type|Description|\n|----|-----------|\n|GlideQueryCondition|Records where the relationships match.|\n\nFind problems that have incidents using the open\\_by field at the join key instead of the sys\\_id.\n\n```\nvar now_GR = new GlideRecord('problem'); \nnow_GR.addJoinQuery('incident', 'opened_by'); \nnow_GR.query();\n```\n\n### Scoped equivalent\n\nTo use the addJoinQuery\\(\\) method in a scoped application, use the corresponding scoped method: [addJoinQuery\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - addJoinQuery\\(String table, String primaryField, String joinTableField\\)\n\nAdds a filter to return records based on a relationship in a related table.\n\nFor example, find all the users that are in the database group \\(users via sys\\_user\\_grmember table\\). Another example would be find all problems that have an assigned incident \\(problems via the incident.problem\\_id relationship\\).\n\nThis is not a true database join; rather, addJoinQuery\\(\\) adds a subquery. So, while the result set is limited based on the join, the only fields that you have access to are those on the base table \\(those which are in the table with which the GlideRecord was initialized\\).\n\nAlways test queries on a sub-production instance prior to deploying them on a production instance. An incorrectly constructed encoded query, such as including an invalid field name, produces an invalid query. When the invalid query is run, the invalid part of the query condition is dropped, and the results are based on the valid part of the query, which may return all records from the table. Using an insert\\(\\), update\\(\\), deleteRecord\\(\\), or deleteMultiple\\(\\) method on bad query results can result in data loss.\n\nYou can set the **glide.invalid\\_query.returns\\_no\\_rows** system property to true to have queries with invalid encoded queries return no records. In some cases, the query may still return records in API results even when **glide.invalid\\_query.returns\\_no\\_rows** is set to true. This happens in queries where an invalid query term is used with a WHERE operator. In such queries, the WHERE operator ignores the invalid term\\(s\\) but still interprets and returns the rest of the query statement. For more information about this system property and its functionality, see [Available system properties](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/r_AvailableSystemProperties.md).\n\n|Name|Type|Description|\n|----|----|-----------|\n|table|String|Table name|\n|primaryField|String|If other than sys\\_id, the primary field.|\n|joinTableField|String|If other than sys\\_id, the field that joins the tables|\n\n|Type|Description|\n|----|-----------|\n|GlideQueryCondition|Records where the relationships match.|\n\nFind problems that have incidents associated where the incident caller\\_id field value matches that of the problem opened\\_by field.\n\n```\nvar now_GR = new GlideRecord('problem'); \nnow_GR.addJoinQuery('incident', 'opened_by', 'caller_id'); \nnow_GR.query();\n```\n\n### Scoped equivalent\n\nTo use the addJoinQuery\\(\\) method in a scoped application, use the corresponding scoped method: [addJoinQuery\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - addNotNullQuery\\(String fieldName\\)\n\nAdds a filter to return records where the specified field is not null.\n\n|Name|Type|Description|\n|----|----|-----------|\n|fieldName|String|The field name.|\n\n|Type|Description|\n|----|-----------|\n|GlideQueryCondition|GlideQueryCondition of records where the parameter field is not null.|\n\n```\nvar target = new GlideRecord('incident'); \n  target.addNotNullQuery('short_description');\n  target.query();   // Issue the query to the database to get all records\n  while (target.next()) {   \n     // add code here to process the incident record\n  }\n```\n\n### Scoped equivalent\n\nTo use the addNotNullQuery\\(\\) method in a scoped application, use the corresponding scoped method: [addNotNullQuery\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - addNullQuery\\(String fieldName\\)\n\nAdds a filter to return records where the specified field is null.\n\n|Name|Type|Description|\n|----|----|-----------|\n|fieldName|String|The field name.|\n\n|Type|Description|\n|----|-----------|\n|GlideQueryCondition|GlideQueryCondition of records where the specified field is null.|\n\n```\nvar target = new GlideRecord('incident'); \n  target.addNullQuery('short_description');\n  target.query();   // Issue the query to the database to get all records\n  while (target.next()) {   \n     // add code here to process the incident record\n  }\n```\n\n### Scoped equivalent\n\nTo use the addNullQuery\\(\\) method in a scoped application, use the corresponding scoped method: [addNullQuery\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - addQuery\\(String name, Object operator, Object value\\)\n\nProvides the ability to build a request, which when executed, returns the rows from the specified table that match the request.\n\nIf you're familiar with SQL, this method is similar to the \"where\" clause. You can make one or more addQuery\\(\\) calls in a single query. For this method the queries are AND'ed. If any of the query statements need to be OR'ed, use the class [GlideQueryCondition](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideQueryConditionAPI.md).\n\naddQuery\\(\\) is typically called with three parameters; table field, operator, and comparison value. It can be called with only two parameters, table field and comparison value, such as `myObj.addQuery('category','Hardware');`. The operator in this case is assumed to be \"equal to\".\n\nFor additional information on using queries, see [Querying tables in script](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/scripts/c_UsingGlideRecordToQueryTables.md).\n\nAlways test queries on a sub-production instance prior to deploying them on a production instance. An incorrectly constructed encoded query, such as including an invalid field name, produces an invalid query. When the invalid query is run, the invalid part of the query condition is dropped, and the results are based on the valid part of the query, which may return all records from the table. Using an insert\\(\\), update\\(\\), deleteRecord\\(\\), or deleteMultiple\\(\\) method on bad query results can result in data loss.\n\nYou can set the **glide.invalid\\_query.returns\\_no\\_rows** system property to true to have queries with invalid encoded queries return no records. In some cases, the query may still return records in API results even when **glide.invalid\\_query.returns\\_no\\_rows** is set to true. This happens in queries where an invalid query term is used with a WHERE operator. In such queries, the WHERE operator ignores the invalid term\\(s\\) but still interprets and returns the rest of the query statement. For more information about this system property and its functionality, see [Available system properties](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/r_AvailableSystemProperties.md).\n\n**Note:** To enforce query access based on the user, use[addUserQuery\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md).\n\n<table id=\"table_ix2_hvp_dt\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nname\n\n</td><td>\n\nString\n\n</td><td>\n\nTable field name or path to an attribute within a dynamic attribute store element.Format of the attribute path: `dyn_att_field->attr_name`\n\n-   `dyn_att_field`: Name of a dynamic attribute store field on the table.\n-   `attr_name`: Name of the dynamic attribute.\n\nTable: Dynamic Attribute \\[dynamic\\_attribute\\]\n\n\nSee also [Dynamic Schema](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/dynamic-schema.md).\n\n</td></tr><tr><td>\n\noperator\n\n</td><td>\n\nObject\n\n</td><td>\n\nQuery operator. The available values are dependent on the data type of the *value* parameter.Numbers:\n\n-   =\n-   !=\n-   &gt;\n-   &gt;=\n-   &lt;\n-   &lt;=\n\nStrings \\(must be in upper case\\):\n\n-   =\n-   !=\n-   IN\n-   NOT IN\n-   STARTSWITH\n-   ENDSWITH\n-   CONTAINS\n-   DOES NOT CONTAIN\n-   INSTANCEOF\n\n**Note:** Use CONTAINS instead of the LIKE operator.\n\nDynamic schema operators:\n\n-   =\n-   !=\n-   &lt;\n-   &gt;\n-   &lt;=\n-   &gt;=\n-   BETWEEN\n-   CONTAINS\n-   DOES\\_NOT\\_CONTAIN\n-   ENDSWITH\n-   GT\\_FIELD\n-   GT\\_OR\\_EQUALS\\_FIELD\n-   IN\n-   ISEMPTY\n-   ISNOTEMPTY\n-   IS\\_NOT\\_NULL\n-   IS\\_NULL\n-   LIKE\n-   LT\\_FIELD\n-   LT\\_OR\\_EQUALS\\_FIELD\n-   MATCHES\n-   NOT\\_IN\n-   NOT\\_LIKE\n-   NOT\\_MATCHES\n-   NSAMEAS\n-   SAMEAS\n-   STARTSWITH\n\n</td></tr><tr><td>\n\nvalue\n\n</td><td>\n\nObject\n\n</td><td>\n\nValue on which to query \\(not case-sensitive\\).\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|GlideQueryCondition|Reference to the GlideQueryCondition that was added to the GlideRecord.|\n\nThe following example shows how to call this method.\n\n```\nvar rec = new GlideRecord('incident');\nrec.addQuery('active',true);\nrec.addQuery('sys_created_on', \">\", \"2010-01-19 04:05:00\");\nrec.query();\nwhile (rec.next()) { \n rec.active = false;\n gs.print('Active incident ' + rec.number + ' closed');\n rec.update();\n}\n```\n\nThe following example shows how to use the `IN` operator.\n\n```\nvar que = new GlideRecord('incident');\nque.addQuery('number','IN','INC00001,INC00002');\nque.query();\nwhile(que.next()) {\n //do something....\n}\n```\n\nThe following example shows how to call this method using attributes in a dynamic attribute store.\n\n```\nvar gr_Inc = new GlideRecord('incident');\ngr_Inc.addQuery('inc_dynamic_schema->avg_mpg', 'GT_FIELD', 'inc_dynamic_schema2->avg_mpg'); \ngr_Inc.query();\nwhile(gr_Inc.next()) {\n    gs.info(gr_Inc.number + \" Gas Mileage 1: \" + gr_Inc.getDynamicAttributeValue('inc_dynamic_schema->avg_mpg') +  \" GT_FIELD Gas Mileage 2 :\" + gr_Inc.getDynamicAttributeValue('inc_dynamic_schema2->avg_mpg'));\n}\n```\n\n### Scoped equivalent\n\nTo use the addQuery\\(\\) method in a scoped application, use the corresponding scoped method: [addQuery\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - addSystemEncodedQuery\\(String query\\)\n\nAdds a query using an encoded query string. Use this method to bypass query access.\n\nUse this method when system-level access is intended, so that query ACL enforcement is explicitly bypassed for the user. Use[addUserEncodedQuery\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md) to enforce query access.\n\nAdditional methods for system-level access that bypass query ACL checks:\n\n-   [addSystemOrderBy\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md)\n-   [addSystemOrderByDesc\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md)\n-   [addSystemQuery\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md)\n-   [GlideQueryCondition - addSystemCondition\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideQueryConditionAPI.md)\n-   [GlideQueryCondition - addSystemOrCondition\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideQueryConditionAPI.md)\n\nFor information on using this method with GlideRecordSecure, see [Enforcing query ACLs](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/scripts/p_GlideServerAPIs.md).\n\nAlways test queries on a sub-production instance prior to deploying them on a production instance. An incorrectly constructed encoded query, such as including an invalid field name, produces an invalid query. When the invalid query is run, the invalid part of the query condition is dropped, and the results are based on the valid part of the query, which may return all records from the table. Using an insert\\(\\), update\\(\\), deleteRecord\\(\\), or deleteMultiple\\(\\) method on bad query results can result in data loss.\n\nYou can set the **glide.invalid\\_query.returns\\_no\\_rows** system property to true to have queries with invalid encoded queries return no records. In some cases, the query may still return records in API results even when **glide.invalid\\_query.returns\\_no\\_rows** is set to true. This happens in queries where an invalid query term is used with a WHERE operator. In such queries, the WHERE operator ignores the invalid term\\(s\\) but still interprets and returns the rest of the query statement. For more information about this system property and its functionality, see [Available system properties](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/r_AvailableSystemProperties.md).\n\n|Name|Type|Description|\n|----|----|-----------|\n|query|String|An [encoded query string](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-user-interface/c_EncodedQueryStrings.md).|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\nThe following example shows how to return the number value of the first 12 incidents with a priority value of 1 or 2.\n\n```\nvar queryString = \"priority=1^ORpriority=2\";\nvar now_GR = new GlideRecord('incident');\nnow_GR.addSystemEncodedQuery(queryString);\n\nnow_GR.setLimit(12);\nnow_GR.query();\n\nwhile (now_GR.next()) {\n  gs.info(now_GR.getValue('number'));\n}\n```\n\nOutput:\n\n```\n*** Script: INC0002318\n*** Script: INC0000144\n*** Script: INC0006927\n*** Script: INC0003577\n*** Script: INC0006928\n*** Script: INC0000135\n*** Script: INC0005637\n*** Script: INC0003196\n*** Script: INC0002647\n*** Script: INC0004074\n*** Script: INC0003444\n*** Script: INC0001694\n```\n\n## GlideRecord - addSystemOrderBy\\(String name\\)\n\nSpecifies an orderBy column. Use this method to bypass query access.\n\nUse this method when system-level access is intended, so that query ACL enforcement is explicitly bypassed for the user. Use[addUserOrderBy\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md) to enforce query access.\n\nAdditional methods for system-level access that bypass query ACL checks:\n\n-   [addSystemEncodedQuery\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md)\n-   [addSystemQuery\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md)\n-   [GlideQueryCondition - addSystemCondition\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideQueryConditionAPI.md)\n-   [GlideQueryCondition - addSystemOrCondition\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideQueryConditionAPI.md)\n\nCall this method more than once to order by multiple columns. Results are arranged in ascending order. To arrange records in descending order, see [addSystemOrderByDesc\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md).\n\n|Name|Type|Description|\n|----|----|-----------|\n|name|String|Column name to use to order the records in this GlideRecord object.|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\nThe following example shows how to order incident records in ascending order by Short Description.\n\n```\nvar queryString = \"priority=1\";\nvar now_GR = new GlideRecord('incident');\n\nnow_GR.addSystemOrderBy('short_description'); // Ascending Order\nnow_GR.addSystemEncodedQuery(queryString);\n\nnow_GR.setLimit(6);\nnow_GR.query();\n\nwhile (now_GR.next()) {\n  gs.info(now_GR.getValue('short_description'));\n}\n```\n\nOutput:\n\n```\n*** Script: Access token revoked\n*** Script: Access token revoked\n*** Script: Account locked, pls reset my password for Linkedin Sales Navigator\n*** Script: Active Directory (AD) synchronization error\n*** Script: Adobe Photoshop & Digital Publishing Instance is down\n*** Script: Application response time is poor when performing any action in ADP Payroll S...\n```\n\n## GlideRecord - addSystemOrderByDesc\\(String name\\)\n\nSpecifies a descending orderBy column. Use this method to bypass query access.\n\nUse this method when system-level access is intended, so that query ACL enforcement is explicitly bypassed for the user. Use[addUserOrderByDesc\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md) to enforce query access.\n\nAdditional methods for system-level access that bypass query ACL checks:\n\n-   [addSystemEncodedQuery\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md)\n-   [addSystemQuery\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md)\n-   [GlideQueryCondition - addSystemCondition\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideQueryConditionAPI.md)\n-   [GlideQueryCondition - addSystemOrCondition\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideQueryConditionAPI.md)\n\nCall this method more than once to order by multiple columns. Results are arranged in descending order. To arrange records in ascending order, see [addSystemOrderBy\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md).\n\n|Name|Type|Description|\n|----|----|-----------|\n|name|String|Column name to use to order the records in a GlideRecord object.|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\nThe following example shows how to order incident records in descending order by Short Description.\n\n```\nvar queryString = \"priority=2\";\nvar now_GR = new GlideRecord('incident');\n\nnow_GR.addSystemOrderByDesc('short_description'); //Descending Order\nnow_GR.addSystemEncodedQuery(queryString);\n\nnow_GR.setLimit(6);\nnow_GR.query();\n\nwhile (now_GR.next()) {\n  gs.info(now_GR.getValue('short_description'));\n}\n```\n\nOutput:\n\n```\n*** Script: Xignite U.S. and Global Real Time Quotes upgrade to the latest version\n*** Script: Xignite Company, Market and Industry News Headlines upgrade to the latest ver...\n*** Script: Workday Talent Management Instance relocation from US datacenter to Hongkong ...\n*** Script: Warning displayed while launching Tableau Server\n*** Script: Warning displayed while launching SAP Financial Accounting\n*** Script: Warning displayed while launching Jive Daily\n```\n\n## GlideRecord - addSystemQuery\\(String name, Object operator, Object value\\)\n\nProvides the ability to build a request, which when executed, returns the rows from the specified table, that match the request. Use this method to bypass query access.\n\nUse this method when system-level access is intended, so that query ACL enforcement is explicitly bypassed for the user. Use[addUserQuery\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md) to enforce query access.\n\nAdditional methods for system-level access that bypass query ACL checks:\n\n-   [addSystemEncodedQuery\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md)\n-   [addSystemOrderBy\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md)\n-   [addSystemOrderByDesc\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md)\n-   [GlideQueryCondition - addSystemCondition\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideQueryConditionAPI.md)\n-   [GlideQueryCondition - addSystemOrCondition\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideQueryConditionAPI.md)\n\nAlways test queries on a sub-production instance prior to deploying them on a production instance. An incorrectly constructed encoded query, such as including an invalid field name, produces an invalid query. When the invalid query is run, the invalid part of the query condition is dropped, and the results are based on the valid part of the query, which may return all records from the table. Using an insert\\(\\), update\\(\\), deleteRecord\\(\\), or deleteMultiple\\(\\) method on bad query results can result in data loss.\n\nYou can set the **glide.invalid\\_query.returns\\_no\\_rows** system property to true to have queries with invalid encoded queries return no records. In some cases, the query may still return records in API results even when **glide.invalid\\_query.returns\\_no\\_rows** is set to true. This happens in queries where an invalid query term is used with a WHERE operator. In such queries, the WHERE operator ignores the invalid term\\(s\\) but still interprets and returns the rest of the query statement. For more information about this system property and its functionality, see [Available system properties](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/r_AvailableSystemProperties.md).\n\n<table id=\"table_ix2_hvp_dt\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nname\n\n</td><td>\n\nString\n\n</td><td>\n\nTable field name.\n\n</td></tr><tr><td>\n\noperator\n\n</td><td>\n\nObject\n\n</td><td>\n\nQuery operator. The available values are dependent on the data type of the *value* parameter.Numbers:\n\n-   =\n-   !=\n-   &gt;\n-   &gt;=\n-   &lt;\n-   &lt;=\n\nStrings \\(must be in upper case\\):\n\n-   =\n-   !=\n-   IN\n-   NOT IN\n-   STARTSWITH\n-   ENDSWITH\n-   CONTAINS\n-   DOES NOT CONTAIN\n-   INSTANCEOF\n\n**Note:** Use CONTAINS instead of the LIKE operator.\n\nDynamic schema operators:\n\n-   =\n-   !=\n-   &lt;\n-   &gt;\n-   &lt;=\n-   &gt;=\n-   BETWEEN\n-   CONTAINS\n-   DOES\\_NOT\\_CONTAIN\n-   ENDSWITH\n-   GT\\_FIELD\n-   GT\\_OR\\_EQUALS\\_FIELD\n-   IN\n-   ISEMPTY\n-   ISNOTEMPTY\n-   IS\\_NOT\\_NULL\n-   IS\\_NULL\n-   LIKE\n-   LT\\_FIELD\n-   LT\\_OR\\_EQUALS\\_FIELD\n-   MATCHES\n-   NOT\\_IN\n-   NOT\\_LIKE\n-   NOT\\_MATCHES\n-   NSAMEAS\n-   SAMEAS\n-   STARTSWITH\n\n</td></tr><tr><td>\n\nvalue\n\n</td><td>\n\nObject\n\n</td><td>\n\nValue on which to query \\(not case-sensitive\\).\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|[GlideQueryCondition](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideQueryConditionAPI.md)|The query condition that was added to the GlideRecord.|\n\nThe following example shows how to explicitly return all active users named Fred.\n\n```\nvar rec = new GlideRecord('sys_user');\nrec.addSystemQuery(\"first_name\", \"=\", \"Fred\");\nrec.query();\n\nwhile (rec.next()) {\n  gs.info('Active user ' + rec.getValue('last_name'));\n}\n```\n\nOutput:\n\n```\nActive user Luddy\nActive user Kunde\n```\n\n## GlideRecord - addUserEncodedQuery\\(String query\\)\n\nAdds a query using an encoded query string. Use this method to enforce query access based on the user.\n\nThis method returns only records that the current user has query access to \\(based on ACLs\\).\n\nRelated methods:\n\n-   [addEncodedQuery\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md) provides the same functionality without ACL enforcement.\n-   [addSystemEncodedQuery\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md) bypasses query access checks.\n\nAdditional methods for enforcing query ACL checks:\n\n-   [addUserOrderBy\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md)\n-   [addUserOrderByDesc\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md)\n-   [addUserQuery\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md)\n-   [GlideQueryCondition - addUserCondition\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideQueryConditionAPI.md)\n-   [GlideQueryCondition - addUserOrCondition\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideQueryConditionAPI.md)\n\nFor information on using this method with GlideRecordSecure, see [Enforcing query ACLs](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/scripts/p_GlideServerAPIs.md).\n\nAlways test queries on a sub-production instance prior to deploying them on a production instance. An incorrectly constructed encoded query, such as including an invalid field name, produces an invalid query. When the invalid query is run, the invalid part of the query condition is dropped, and the results are based on the valid part of the query, which may return all records from the table. Using an insert\\(\\), update\\(\\), deleteRecord\\(\\), or deleteMultiple\\(\\) method on bad query results can result in data loss.\n\nYou can set the **glide.invalid\\_query.returns\\_no\\_rows** system property to true to have queries with invalid encoded queries return no records. In some cases, the query may still return records in API results even when **glide.invalid\\_query.returns\\_no\\_rows** is set to true. This happens in queries where an invalid query term is used with a WHERE operator. In such queries, the WHERE operator ignores the invalid term\\(s\\) but still interprets and returns the rest of the query statement. For more information about this system property and its functionality, see [Available system properties](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/r_AvailableSystemProperties.md).\n\n|Name|Type|Description|\n|----|----|-----------|\n|query|String|An [encoded query string](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-user-interface/c_EncodedQueryStrings.md).|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\nThe following example shows how to return the number value of the first 12 incidents with a priority value of 1 or 2.\n\n```\nvar queryString = \"priority=1^ORpriority=2\";\nvar now_GR = new GlideRecord('incident');\nnow_GR.addUserEncodedQuery(queryString);\n\nnow_GR.setLimit(12);\nnow_GR.query();\n\nwhile (now_GR.next()) {\n  gs.info(now_GR.getValue('number'));\n}\n```\n\nOutput:\n\n```\n*** Script: INC0002318\n*** Script: INC0000144\n*** Script: INC0006927\n*** Script: INC0003577\n*** Script: INC0006928\n*** Script: INC0000135\n*** Script: INC0005637\n*** Script: INC0003196\n*** Script: INC0002647\n*** Script: INC0004074\n*** Script: INC0003444\n*** Script: INC0001694\n```\n\n## GlideRecord - addUserOrderBy\\(String name\\)\n\nSpecifies an orderBy column. Use this method to enforce query access based on the user.\n\nThis method returns only records that the current user has query access to \\(based on ACLs\\).\n\nRelated methods:\n\n-   [orderBy\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md) provides the same functionality without ACL enforcement.\n-   [addSystemOrderBy\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md) bypasses query access checks.\n\nAdditional methods for enforcing query ACL checks:\n\n-   [addUserEncodedQuery\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md)\n-   [addUserQuery\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md)\n-   [GlideQueryCondition - addUserCondition\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideQueryConditionAPI.md)\n-   [GlideQueryCondition - addUserOrCondition\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideQueryConditionAPI.md)\n\nCall this method more than once to order by multiple columns. Results are arranged in ascending order. To arrange records in descending order, see [addUserOrderByDesc\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md).\n\n|Name|Type|Description|\n|----|----|-----------|\n|name|String|Column name to use to order the records in this GlideRecord object.|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\nThe following example shows how to order incident records in ascending order by Short Description.\n\n```\nvar queryString = \"priority=1\";\nvar now_GR = new GlideRecord('incident');\n\nnow_GR.addUserOrderBy('short_description'); // Ascending Order\nnow_GR.addUserEncodedQuery(queryString);\n\nnow_GR.setLimit(6);\nnow_GR.query();\n\nwhile (now_GR.next()) {\n  gs.info(now_GR.getValue('short_description'));\n}\n```\n\nOutput:\n\n```\n*** Script: Access token revoked\n*** Script: Access token revoked\n*** Script: Account locked, pls reset my password for Linkedin Sales Navigator\n*** Script: Active Directory (AD) synchronization error\n*** Script: Adobe Photoshop & Digital Publishing Instance is down\n*** Script: Application response time is poor when performing any action in ADP Payroll S...\n```\n\n## GlideRecord - addUserOrderByDesc\\(String name\\)\n\nSpecifies a descending orderBy column. Use this method to enforce query access based on the user.\n\nThis method returns only records that the current user has query access to \\(based on ACLs\\).\n\nRelated methods:\n\n-   [orderByDesc\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md) provides the same functionality without ACL enforcement.\n-   [addSystemOrderByDesc\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md) bypasses query access checks.\n\nAdditional methods for enforcing query ACL checks:\n\n-   [addUserEncodedQuery\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md)\n-   [addUserQuery\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md)\n-   [GlideQueryCondition - addUserCondition\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideQueryConditionAPI.md)\n-   [GlideQueryCondition - addUserOrCondition\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideQueryConditionAPI.md)\n\nCall this method more than once to order by multiple columns. Results are arranged in descending order. To arrange records in ascending order, see [addUserOrderBy\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md).\n\n|Name|Type|Description|\n|----|----|-----------|\n|name|String|Column name to use to order the records in a GlideRecord object.|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\nThe following example shows how to order incident records in descending order by Short Description.\n\n```\nvar queryString = \"priority=2\";\nvar now_GR = new GlideRecord('incident');\n\nnow_GR.addUserOrderByDesc('short_description'); //Descending Order\nnow_GR.addUserEncodedQuery(queryString);\n\nnow_GR.setLimit(6);\nnow_GR.query();\n\nwhile (now_GR.next()) {\n  gs.info(now_GR.getValue('short_description'));\n}\n```\n\nOutput:\n\n```\n*** Script: Xignite U.S. and Global Real Time Quotes upgrade to the latest version\n*** Script: Xignite Company, Market and Industry News Headlines upgrade to the latest ver...\n*** Script: Workday Talent Management Instance relocation from US datacenter to Hongkong ...\n*** Script: Warning displayed while launching Tableau Server\n*** Script: Warning displayed while launching SAP Financial Accounting\n*** Script: Warning displayed while launching Jive Daily\n```\n\n## GlideRecord - addUserQuery\\(String name, Object operator, Object value\\)\n\nProvides the ability to build a request, which when executed, returns the rows from the specified table that match the request. The calling user must have access to perform the specified query operation on the field for this request to be added. Use this method to enforce query access based on the user.\n\nThis method returns only records that the current user has query access to \\(based on ACLs\\).\n\nRelated methods:\n\n-   [addQuery\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md) provides the same functionality without ACL enforcement.\n-   [addSystemQuery\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md) bypasses query access checks.\n\nAdditional methods for enforcing query ACL checks:\n\n-   [addUserOrderBy\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md)\n-   [addUserEncodedQuery\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md)\n-   [addUserOrderByDesc\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md)\n-   [GlideQueryCondition - addUserCondition\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideQueryConditionAPI.md)\n-   [GlideQueryCondition - addUserOrCondition\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideQueryConditionAPI.md)\n\nAlways test queries on a sub-production instance prior to deploying them on a production instance. An incorrectly constructed encoded query, such as including an invalid field name, produces an invalid query. When the invalid query is run, the invalid part of the query condition is dropped, and the results are based on the valid part of the query, which may return all records from the table. Using an insert\\(\\), update\\(\\), deleteRecord\\(\\), or deleteMultiple\\(\\) method on bad query results can result in data loss.\n\nYou can set the **glide.invalid\\_query.returns\\_no\\_rows** system property to true to have queries with invalid encoded queries return no records. In some cases, the query may still return records in API results even when **glide.invalid\\_query.returns\\_no\\_rows** is set to true. This happens in queries where an invalid query term is used with a WHERE operator. In such queries, the WHERE operator ignores the invalid term\\(s\\) but still interprets and returns the rest of the query statement. For more information about this system property and its functionality, see [Available system properties](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/r_AvailableSystemProperties.md).\n\n<table id=\"table_ix2_hvp_dt\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nname\n\n</td><td>\n\nString\n\n</td><td>\n\nTable field name.\n\n</td></tr><tr><td>\n\noperator\n\n</td><td>\n\nObject\n\n</td><td>\n\nQuery operator. The available values are dependent on the data type of the *value* parameter.Numbers:\n\n-   =\n-   !=\n-   &gt;\n-   &gt;=\n-   &lt;\n-   &lt;=\n\nStrings \\(must be in upper case\\):\n\n-   =\n-   !=\n-   IN\n-   NOT IN\n-   STARTSWITH\n-   ENDSWITH\n-   CONTAINS\n-   DOES NOT CONTAIN\n-   INSTANCEOF\n\n**Note:** Use CONTAINS instead of the LIKE operator.\n\nDynamic schema operators:\n\n-   =\n-   !=\n-   &lt;\n-   &gt;\n-   &lt;=\n-   &gt;=\n-   BETWEEN\n-   CONTAINS\n-   DOES\\_NOT\\_CONTAIN\n-   ENDSWITH\n-   GT\\_FIELD\n-   GT\\_OR\\_EQUALS\\_FIELD\n-   IN\n-   ISEMPTY\n-   ISNOTEMPTY\n-   IS\\_NOT\\_NULL\n-   IS\\_NULL\n-   LIKE\n-   LT\\_FIELD\n-   LT\\_OR\\_EQUALS\\_FIELD\n-   MATCHES\n-   NOT\\_IN\n-   NOT\\_LIKE\n-   NOT\\_MATCHES\n-   NSAMEAS\n-   SAMEAS\n-   STARTSWITH\n\n</td></tr><tr><td>\n\nvalue\n\n</td><td>\n\nObject\n\n</td><td>\n\nValue on which to query \\(not case-sensitive\\).\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|[GlideQueryCondition](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideQueryConditionAPI.md)|The query condition that was added to the GlideRecord.|\n\nThe following shows how to return only users named Fred that the current user has permission to see.\n\n```\nvar rec = new GlideRecord('sys_user');\nrec.addUserQuery(\"first_name\", \"=\", \"Fred\");\nrec.query();\n\nwhile (rec.next()) {\n  gs.info('Active user ' + rec.getValue('last_name'));\n}\n```\n\nOutput:\n\n```\nActive user Luddy\nActive user Kunde\n```\n\n## GlideRecord - addValue\\(String field, Number value\\)\n\nProvides atomic add and subtract operations on a specified number field at the database level for the current GlideRecord object.\n\nTypically, a GlideRecord object is written as one record in a database. Individual field values are stored as defined. For code that adds a value to a GlideRecord field, it simply saves the field to the database with the new value, rather than atomically incrementing it.\n\nFor example, when the following code is executed, the value of the u\\_count field in the database is 2.\n\n```\ngs.print(now_now_GR.u_count); // \"1\" \nnow_GR.u_count += 1; \nnow_GR.update(); \nnow_GR.get(now_now_GR.sys_id); \ngs.print(now_now_GR.u_count); // \"2\"   \n```\n\nIf another user concurrently runs identical code, instead of the two operations each adding 1 to u\\_count, the net effect is that u\\_count only contains 2, with one operation's update actually being lost.\n\nConversely, the addValue\\(\\) method performs the addition/subtraction in the database when the record is updated as an atomic operation. Two operations running concurrently each properly update the field.\n\n```\ngs.print(now_now_GR.u_count); // \"1\" \nnow_GR.addValue(\"u_count\", 1); \nnow_GR.update(); \nnow_GR.get(now_GR); // The record must be reloaded from the database to observe the result\ngs.print(now_now_GR.u_count); // \"3\", if executed concurrently with another user \n```\n\n**Note:** The new value is not read back from the database unless explicitly done so.\n\nLike setValue\\(\\), addValue\\(\\) changes only take effect in the database after a subsequent call to update\\(\\) or insert\\(\\). If insert\\(\\) is called, the specified field is initialized with the **value** parameter passed into addValue\\(\\).\n\n**Note:** If setValue\\(\\) is called for the specified field prior to calling addValue\\(\\), the addValue\\(\\) method is not processed and an error message is logged.\n\n<table id=\"table_h43_tjt_hlb\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nfield\n\n</td><td>\n\nString\n\n</td><td>\n\nThe name of the field in this GlideRecord to modify. If the associated field is not a numeric type, the operation is ignored.\n\n</td></tr><tr><td>\n\nvalue\n\n</td><td>\n\nNumber\n\n</td><td>\n\nThe amount to add to the value when the record is saved. To perform a subtraction operation, simply pass a negative value.\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|void| |\n\nShows a value being added.\n\n```\ngs.print(now_GR.u_count); // \"1\" \nnow_GR.addValue(\"u_count\", 1); \nnow_GR.update(); \nnow_GR.get(now_GR.sys_id); // The record must be reloaded from the database to observe the result\ngs.print(now_GR.u_count);\n```\n\nOutput: 2\n\nShows a value being subtracted.\n\n```\ngs.print(now_GR.u_count); // \"4\" \nnow_GR.addValue(\"u_count\", -1); \nnow_GR.update(); \nnow_GR.get(now_GR.sys_id); // The record must be reloaded from the database to observe the result\ngs.print(now_GR.u_count);\n```\n\nOutput: 3\n\n## GlideRecord - applyEncodedQuery\\(String queryString\\)\n\nSets the values of the specified encoded query terms and applies them to the current GlideRecord.\n\n|Name|Type|Description|\n|----|----|-----------|\n|queryString|String|Encoded query to apply to the current GlideRecord.|\n\n|Type|Description|\n|----|-----------|\n|None| |\n\n```\nfunction createAcl(table, role) {\n  gs.print(\"Checking security on table \" + table);\n  var now_GR = new GlideRecord(\"sys_security_acl\");\n  now_GR.addQuery(\"name\", table);\n  now_GR.addQuery(\"operation\", \"read\");\n  now_GR.query();\n  var encQuery = now_GR.getEncodedQuery();\n  if (now_GR.next()) {\n    // existing acl found so use it\n    createAclRole(now_GR.sys_id.toString(), role);\n    return;\n  } else {\n  now_GR.initialize();\n  now_GR.applyEncodedQuery(encQuery);\n  var acl = now_GR.insert();\n    gs.print(\"Added read access control on \" + table);\n    createAclRole(acl, role);\n  } \n}\n```\n\n## GlideRecord - applyTemplate\\(String template\\)\n\nApply a template record from the Template table \\[sys\\_template\\] to the current record. If the specified template is not found, no action is taken.\n\n**Note:** This method automatically instantiates a now\\_GR.insert\\(\\) method if a template has the **Next Related Child Template** field filled. For information, see [Create templates for related task records](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/create-templates-for-related-task-records.md).\n\n|Name|Type|Description|\n|----|----|-----------|\n|template|String|Name of a template from the Templates \\[sys\\_template\\] table.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n```\nvar rec1 = new GlideRecord(\"incident\");\nrec1.initialize();\nrec1.applyTemplate(\"my_incident_template\");\nrec1.insert();\n```\n\n## GlideRecord - autoSysFields\\(Boolean e\\)\n\nEnables or disables the update to the fields sys\\_updated\\_by, sys\\_updated\\_on, sys\\_mod\\_count, sys\\_created\\_by, and sys\\_created\\_on. This is often used for manually updating field values on a record while leaving historical information unchanged.\n\n**Warning:** Use caution if you use this method. When you use this method the sys\\_mod\\_count field will not be incremented, and other sys\\_ fields will not be updated. This can break functionality including, but not limited to, the Activity Formatter, History Sets, Notifications, and Metrics.\n\n|Name|Type|Description|\n|----|----|-----------|\n|e|Boolean|If false disables updates to sys\\_updated\\_by, sys\\_updated\\_on, sys\\_mod\\_count, sys\\_created\\_by, and sys\\_created\\_on.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n```\nvar inc = new GlideRecord('incident');\n \n// Change all Open(1) incidents to Active(2)\n \ninc.addQuery('state', 1);\ninc.query();\n \nwhile (inc.next()) {\n  inc.autoSysFields(false);  // Do not update sys_updated_by, sys_updated_on, sys_mod_count, sys_created_by, and sys_created_on\n  inc.setWorkflow(false);    // Do not run any other business rules\n  inc.setValue('state', 2);\n  inc.update();\n}\n```\n\n## GlideRecord - canCreate\\(\\)\n\nDetermines if the access control rules \\(which includes the user's role\\) permit inserting new records in this table.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n<table id=\"table_ryz_pwp_dt\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether the user's roles permit creating of records in this table.Possible values:\n\n-   true: Creating permitted\n-   false: Creating is not permitted\n\n</td></tr></tbody>\n</table>This example shows whether records can be created on the benefit\\_plan table.\n\n```\ncanCreateBenefitPlan : function() {\n  var now_GR = new GlideRecord('benefit_plan');\n  return now_GR.canCreate();\n}\n```\n\n### Scoped equivalent\n\nTo use the canCreate\\(\\) method in a scoped application, use the corresponding scoped method: [canCreate\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - canDelete\\(\\)\n\nDetermines if the access control rules \\(which includes the user's role\\) permit deletion of records in this table.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n<table id=\"table_lmz_zwp_dt\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether the user's roles permit deleting of records in this table.Valid values:\n\n-   true: Deleting permitted\n-   false: Deleting is not permitted\n\n</td></tr></tbody>\n</table>```\nvar att = new GlideRecord('sys_attachment');\natt.get('$[sys_attachment.sys_id]');\nvar sm = GlideSecurityManager.get();\nvar checkMe = 'record/sys_attachment/delete';\nvar canDelete = sm.hasRightsTo(checkMe, att);\ngs.log('canDelete: ' + canDelete);\n```\n\n### Scoped equivalent\n\nTo use the canDelete\\(\\) method in a scoped application, use the corresponding scoped method: [canDelete\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - canRead\\(\\)\n\nIndicates whether the Access Control Rules \\(ACLs\\) permit the current user to read the current record within the associated GlideRecord table. This method evaluates all available ACLs for the specific resource.\n\n**Note:** You shouldn’t use this method to check for table-level access. A single call to this method might not be sufficient to get a conclusive table-level access rights check result. To perform a table-level access check, use the GlideSecurityManager.hasRightsTo\\(\\) method.\n\nFor additional information on ACLs, see [Access Controls Evaluation Order](https://developer.servicenow.com/dev.do#!/learn/learning-plans/yokohama/servicenow_application_developer/app_store_learnv2_securingapps_yokohama_access_controls_evaluation_order).\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n<table id=\"table_d3g_4xp_dt\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether the user's roles permit reading of the current record.Valid values:\n\n-   true: Reading permitted\n-   false: Reading isn't permitted\n\n</td></tr></tbody>\n</table>This example shows how to iterate through the Incident \\[incident\\] table and check if the user has read rights to each record.\n\n```\nvar grTable = new GlideRecord('incident');\ngrTable.query();\nwhile (grTable.next()) {\n  if (grTable.canRead()) \n\t\t…\n}\n```\n\n### Scoped equivalent\n\nTo use the canRead\\(\\) method in a scoped application, use the corresponding scoped method: [canRead\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - canWrite\\(\\)\n\nDetermines if the access control rules \\(which includes the user's role\\) permit updates to records in this table.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n<table id=\"table_trp_xxp_dt\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether the user's roles permit writing of records in this table.Valid values:\n\n-   true: Writing permitted\n-   false: Writing is not permitted\n\n</td></tr></tbody>\n</table>This example shows whether records can be written to the benefit\\_plan table.\n\n```\ncanWriteBenefitPlan : function() {\n  var now_GR = new GlideRecord('benefit_plan');\n  return now_GR.canWrite();\n}\n```\n\n### Scoped equivalent\n\nTo use the canWrite\\(\\) method in a scoped application, use the corresponding scoped method: [canWrite\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - changes\\(\\)\n\nDetermines whether any of the fields in the record have changed.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n<table id=\"table_pfg_gyp_dt\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether there are changes in the specified record.Possible values:\n\n-   true: Fields in the specified record have changed.\n-   false: No fields have changed.\n\n</td></tr></tbody>\n</table>This example shows how to check if there are changes in an incident record.\n\n```\nvar now_GR = new GlideRecord(\"incident\");\nnow_GR.query();\nnow_GR.next();\nif (now_GR.changes()) {\n  gs.print(\"The incident record reported changes right after being read\");\n} else {\n  gs.print(\"The incident record has not changed\");\n}\n```\n\n### Scoped equivalent\n\nTo implement this functionality in a scoped application, add code similar to the following:\n\n```\nvar now_GR = new GlideRecord(\"incident\");\n   now_GR.get(\"965c9e5347c12200e0ef563dbb9a7156\");\n   now_GR.short_description = \"test\";\n   var elements = now_GR.getElements();\n   var hasChanged = false;\n   for(var i=0; i < elements.length;i++){\n     var element = elements[i];\n     hasChanged = hasChanged || element.changes();\n     gs.info(element.getName() + \":\" + element.changes());\n   }\n   gs.info(hasChanged);\n```\n\n## GlideRecord - chooseWindow\\(Number firstRow, Number lastRow, Boolean forceCount\\)\n\nSets a range of rows to be returned by subsequent queries.\n\n-   **Using setLimit\\(\\) with chooseWindow\\(\\)**\n\n    The setLimit\\(\\) method implicitly calls the chooseWindow\\(\\) method and might cause unexpected results when used with chooseWindow\\(\\) in a query.\n\n    -   If the chooseWindow\\(\\) method is called first, its record window is overwritten by the setLimit\\(\\) method.\n\n        Using the following lines in a query returns 100 records starting at row 1:\n\n        ```\n        grIncident.chooseWindow(20,30);\n        grIncident.setLimit(100);\n        ```\n\n    -   If the setLimit\\(\\) method is called first, the window set by chooseWindow\\(\\) is used and the limit is overwritten.\n\n        Using the following lines in a query returns 10 records starting at row 21:\n\n        ```\n        grIncident.setLimit(5);\n        grIncident.chooseWindow(20,30);\n        ```\n\n        **Note:** Running query\\(\\) with the chooseWindow\\(\\) method triggers a `COUNT(*)` query, which can result in slow performance on tables with a large number of records. You can use setLimit\\(\\) before chooseWindow\\(\\) to skip running the `COUNT(*)` query, but the same performance benefit is achievable using setNoCount\\(\\).\n\n\nSee also:\n\n-   [query\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md)\n-   [setLimit\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md)\n-   [setNoCount\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md)\n\n<table id=\"table_vy2_525_jq\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nfirstRow\n\n</td><td>\n\nNumber\n\n</td><td>\n\nZero-based index of the starting row for the range, inclusive. \\(A value of 0 returns the first row.\\)\n\n</td></tr><tr><td>\n\nlastRow\n\n</td><td>\n\nNumber\n\n</td><td>\n\nZero-based index of the ending row for the range, exclusive.For example, if **firstRow** = 1 and **lastRow** = 5, four records are returned \\(2-5\\).\n\n</td></tr><tr><td>\n\nforceCount\n\n</td><td>\n\nBoolean\n\n</td><td>\n\nOptional. Flag that indicates whether to force a row count query. In most implementations of this call, the row count is performed. There are some outlying cases, such as text searches, were a row count is not performed. Setting this flag ensures that the row count occurs.Valid values:\n\n-   true: Row count always occurs.\n-   false: Row count occurs if implemented in normal execution of method.\n\n Default: false\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|void| |\n\nThis example shows how to return records 3 and 4 from the Incident \\[incident\\] table.\n\n```\nvar now_GR = new GlideRecord('incident');\nnow_GR.orderBy('number');\nnow_GR.chooseWindow(2, 4);\nnow_GR.query();\nwhile (now_GR.next()) {\n  gs.info(now_GR.getValue('number') + ' is within window');\n}\n```\n\nOutput:\n\n```\n*** Script: INC0000003 is within window\n*** Script: INC0000004 is within window\n```\n\n## GlideRecord - deleteMultiple\\(\\)\n\nDeletes all records that satisfy the query.\n\nThis method does not delete attachments.\n\nDot-walking is not supported for this method. When using the deleteMultiple\\(\\) function on referenced tables, all the records in the table are deleted. Also, when using deleteRecord\\(\\) to cascade delete, prior calls to setWorkflow\\(\\) on the same GlideRecord object are ignored.\n\nDo not use deleteMultiple\\(\\) on tables with currency fields. Always delete each record individually. Also, do not use this method with the chooseWindow\\(\\) or setLimit\\(\\) methods when working with large tables. The setLimit\\(\\) method does not limit the number of records that are deleted with deleteMultiple\\(\\). All records returned by the query are deleted regardless of setLimit\\(\\).\n\nThe **glide.db.forced.chunk.threshold** system property sets the threshold above which forces chunk record deletions and updates. Chunking helps to prevent non-primary key deletions on huge tables from causing replication problems. For more information, see [Available system properties](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/r_AvailableSystemProperties.md).\n\n**Note:** When using deleteMultiple\\(\\) to cascade delete, prior calls to setWorkflow\\(\\) on the same GlideRecord object are ignored.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|None| |\n\nThis example shows how to delete all inactive records from the Incident table.\n\n```\nvar now_GR = new GlideRecord('incident');\nnow_GR.addQuery('active','false');\nnow_GR.query();\nnow_GR.deleteMultiple();\n```\n\n### Scoped equivalent\n\nTo use the deleteMultiple\\(\\) method in a scoped application, use the corresponding scoped method: [deleteMultiple\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - deleteRecord\\(\\)\n\nDeletes a single record.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n<table id=\"table_yqy_s1x_dt\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether the record was successfully deleted.Possible values:\n\n-   true: Record was deleted.\n-   false: No record was found to delete.\n\n</td></tr></tbody>\n</table>This example shows how to delete all inactive records from the Incident table.\n\n```\nvar rec = new GlideRecord('incident');\nrec.addQuery('active',false);\nrec.query();\nwhile (rec.next()) { \n gs.info('Inactive incident ' + rec.number + ' deleted');\n rec.deleteRecord();\n}\n```\n\nOutput:\n\n```\nInactive incident INC0010010 deleted\nInactive incident INC0010011 deleted\n```\n\nThis example shows how to delete a record from the Incident table immediately after it is inserted. The incident GlideRecord must be reloaded after the insert before it can be deleted.\n\n```\nvar grTicket = new GlideRecord('incident');\ngrTicket.initialize();\ngrTicket.short_description = 'Example ticket';\ngrTicket.work_notes = 'An update about the ticket';\nvar ins_sys_id = grTicket.insert(); // Insert the record\ngrTicket.get(ins_sys_id); // Reload the inserted record\ngs.info(grTicket.deleteRecord()); // Delete the record\n```\n\nOutput:\n\n```\ntrue\n```\n\n### Scoped equivalent\n\nTo use the deleteRecord\\(\\) method in a scoped application, use the corresponding scoped method: [deleteRecord\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - disableSysIdInOptimization\\(\\)\n\nDisables the default optimization that prevents an extra database query from running when a user passes in a large number of sys\\_ids, such as `grIncident.addQuery('sys_id', 'IN', listOf200SysIds)`.\n\nThis method only effects the GlideRecord on which it’s called. To modify the sys\\_id limit optimization for all GlideRecords, adjust the value in the **glide.db.first\\_pass\\_sys\\_id\\_list\\_size.max** system property \\(default 100\\).\n\nIf you don't either call this method or adjust the **glide.db.first\\_pass\\_sys\\_id\\_list\\_size.max** system property and pass a list that contains more sys\\_id entries than defined in **glide.db.first\\_pass\\_sys\\_id\\_list\\_size.max**, the returned value from GlideRecord.getRowCount\\(\\) may be incorrect.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|None| |\n\nThe following code example shows how to use the disableSysIdInOptimiation\\(\\) method to disable the sys\\_id limit optimization when passing an Incident sys\\_id list that contains 200 entries.\n\n```\nvar listOf200SysIds = [ ... ]; // 200 comma separated sys_ids\nvar grIncident = new GlideRecord('incident');\ngrIncident.addQuery('sys_id', 'IN', listOf200SysIds);\ngrIncident.disableSysIdInOptimization(); // Rowcount could be incorrect without this method call\ngrIncident.query();\nif (grIncident.next())\n    gs.info(\"Rowcount: \" + grIncident.getRowCount());\n```\n\nOutput:\n\n```\nRowcount: 200\n```\n\n## GlideRecord - find\\(String columnName, String value\\)\n\nReturns true if any record has a matching value in the specified column. If found, it also moves to the first record that matches, essentially executing next\\(\\) until the record is returned.\n\n**Note:** This method creates a record instead of updating the existing record if you apply the update\\(\\) method after modifying the GlideRecord. To avoid creating a record, call the next\\(\\) method before calling find\\(\\). For example:\n\n```\nvar existingMaterials = new GlideRecord('u_m2m_material_num_service_instance');\nexistingMaterials.addQuery('u_service_instance', serviceInstance.sys_id);\nexistingMaterials.query();\nexistingMaterials.next(); // This line added to prevent new record creation\n\nexistingMaterials.find('u_material_number', 'ca41b9fd37a84200fdc25ca543990ed8');\n\nexistingMaterials.u_material_quantity = 5;\nexistingMaterials.update(\"Modify request via catalog\");\n```\n\nSee also:\n\n-   [next\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md)\n-   [update\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md)\n\n|Name|Type|Description|\n|----|----|-----------|\n|columnName|String|Field name to search.|\n|value|String|Value to check for in the specified field.|\n\n<table id=\"table_l1m_qyp_dt\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether any record within the current table has a matching value in the specified field.Possible values:\n\n-   true: Matching field.\n-   false: No matching field.\n\n</td></tr></tbody>\n</table>This example shows how to find a record in the Incident table with \"Critical\" in the short description field.\n\n```\nvar now_GR = new GlideRecord(\"incident\");\nnow_GR.query();\nvar shortDescription = \"Critical\";\nif (now_GR.find(\"short_description\", shortDescription)) {\n  gs.print(\"An incident with the specified field value was found\");\n  var recordID = now_GR.getValue(\"sys_id\");\n  gs.print(\"Found in the following record: \" + recordID);\n} else {\n  gs.print(\"An incident with the specified field value was not found\");\n}\n```\n\nOutput:\n\n```\nAn incident with the specified field value was found\nFound in the following record: 552c48888c033300964f4932b03eb092\n```\n\n## GlideRecord - get\\(Object name, Object value\\)\n\nReturns the specified record in the current GlideRecord object.\n\nThis method accepts either one or two parameters. If only a single parameter is passed in, the method assumes that it is the sys\\_id of the desired record. If not found, it then tries to match the value against the display value. If two parameters are passed in, the first is the name of the column within the GlideRecord to search. The second is the value to search for. If multiple records are found, use next\\(\\) to access the additional records.\n\n|Name|Type|Description|\n|----|----|-----------|\n|name|Object|Optional. Name of the instantiated GlideRecord column to search for the specified **value** parameter. If only a single parameter is passed in, the method assumes that this parameter is sys\\_id.|\n|value|Object|Value to match. For calculated fields, the value is matched as is rather than running a calculation on a scripted default value for a field in the record.|\n\n<table id=\"table_cwp_pcr_dt\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nBoolean\n\n</td><td>\n\nIndicates whether the requested record was located.Possible values:\n\n-   true: Record was found\n-   false: Record was not found\n\n</td></tr></tbody>\n</table>This example gets an incident record by passing in the sys\\_id.\n\n```\nvar grIncident = new GlideRecord('incident');\nvar returnValue = grIncident.get('99ebb4156fa831005be8883e6b3ee4b9');\ngs.info(returnValue); // logs true or false\ngs.info(grIncident.number); // logs Incident Number\n```\n\nThis example gets an incident record by passing in the column in the record to search and the value to search for.\n\n```\nvar grIncident = new GlideRecord('incident');\nvar returnValue = grIncident.get('caller_id.name','Sylivia Wayland');\ngs.info(returnValue); // logs true or false\ngs.info(grIncident.number); // logs Incident Number\n```\n\n### Scoped equivalent\n\nTo use the get\\(\\) method in a scoped application, use the corresponding scoped method: [get\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - getAttribute\\(String fieldName\\)\n\nReturns the dictionary attributes on the specified field.\n\n|Name|Type|Description|\n|----|----|-----------|\n|fieldName|String|Field name for which to return the dictionary attributes|\n\n|Type|Description|\n|----|-----------|\n|String|Dictionary attributes|\n\nThis example shows how to return the dictionary attributes for \"tree\\_picker\".\n\n```\nfunction doit() {\n  var now_GR = new GlideRecord('sys_user');\n  now_GR.query(\"user_name\",\"admin\");\n  if (now_GR.next()) {\n    gs.print(\"we got one\");\n    gs.print(now_GR.location.getAttribute(\"tree_picker\"));\n  }\n}\n```\n\n### Scoped equivalent\n\nTo use the getAttribute\\(\\) method in a scoped application, use the corresponding scoped method: [getAttribute\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - getClassDisplayValue\\(\\)\n\nReturns the table's label.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|Label that identifies the table.|\n\nThis example prints the label of the passed in table.\n\n```\n// Display the incident table label\nvar now_GR = new GlideRecord(\"incident\");\nvar value = now_GR.getClassDisplayValue();\ngs.info(\"The table label is \" + value + \".\");\n```\n\nOutput:\n\n```\nThe table label is Incident.\n```\n\n### Scoped equivalent\n\nTo use the getClassDisplayValue\\(\\) method in a scoped application, use the corresponding scoped method: [getClassDisplayValue\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - getDisplayValue\\(String name\\)\n\nRetrieves the display value for the current record or the display value of an attribute in a dynamic attribute store.\n\n[Display values](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/c_DisplayValues.md) are manipulated based on the actual value in the database and user or system settings and preferences.\n\nThe display value that is returned is dependent on the field type.\n\n-   Choice fields: The database value may be a number, but the display value is more descriptive.\n-   Date fields: The database value is in UTC format, while the display value is based on the user's time zone.\n-   Encrypted text: The database value is encrypted, while the displayed value is unencrypted based on the user's encryption context.\n-   Reference fields: The database value is sys\\_id, but the display value is the display field of the referenced record.\n\nSee also [Dynamic Schema](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/dynamic-schema.md).\n\n<table id=\"table_kps_f2r_dt\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nname\n\n</td><td>\n\nString\n\n</td><td>\n\nOptional. Only required when requesting the display value for a dynamic attribute. Path to an attribute within a dynamic schema to retrieve.\n\nFormat of the attribute path: `dyn_att_field->attr_name`\n\n-   `dyn_att_field`: Name of a dynamic attribute store field on the table.\n-   `attr_name`: Name of the dynamic attribute.\n\nTable: Dynamic Attribute \\[dynamic\\_attribute\\]\n\n\nSee also [Dynamic Schema](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/dynamic-schema.md).\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|String|Display value for the current record or specified element.|\n\nThis example writes the display value of a specified incident record into the log.\n\n```\nvar now_GR = new GlideRecord('incident');\nnow_GR.get('sys_id','<sys_id>');\ngs.info(now_GR.getDisplayValue());\n```\n\nOutput:\n\n```\nINC0000050\n```\n\nThis example shows how to retrieve the display value of an attribute within a dynamic attribute store element.\n\n```\nvar gr_AppTab = new GlideRecord('application_table'); \ngr_AppTab.setValue('dyn_att_field->attr', 42); \ngr_AppTab.setDisplayValue('dyn_att_field->attr2, true);\ngr_AppTab.update();\ngs.info('Attr value: ' + \ngr_AppTab.getDisplayValue('dyn_att_field->attr);\ngs.info('Attr2 value: ' + \ngr_AppTab.getDisplayValue('dyn_att_field->attr2);\n```\n\nOutput:\n\n```\nAttr value: System error\nAttr2 value: true\n```\n\n### Scoped equivalent\n\nTo use the getDisplayValue\\(\\) method in a scoped application, use the corresponding scoped method: [getDisplayValue\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - getDynamicAttribute\\(String fullPath\\)\n\nReturns the GlideElementDynamicAttribute object for the specified dynamic attribute store path.\n\nDynamic attributes have a defined data type and a sys\\_id. For more details on dynamic attributes, see [Dynamic schema](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/dynamic-schema.md).\n\nSee also:\n\n-   [GlideDynamicAttribute - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideDynamicAttributeAPI.md)\n-   [GlideDynamicAttributeStore - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideDynamicAttStoreAPI.md)\n-   [GlideDynamicNamespace - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideDynamicNamespaceAPI.md)\n\n<table id=\"table_rgk_h1x_1bc\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nfullPath\n\n</td><td>\n\nString\n\n</td><td>\n\nPath to use to locate the desired dynamic attribute. Format of the attribute path: `dyn_att_field->attr_name`\n\n-   `dyn_att_field`: Name of a dynamic attribute store field on the table.\n-   `attr_name`: Name of the dynamic attribute.\n\nTable: Dynamic Attribute \\[dynamic\\_attribute\\]\n\n\nSee also [Dynamic Schema](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/dynamic-schema.md).\n\n</td></tr></tbody>\n</table><table id=\"table_sgk_h1x_1bc\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nObject\n\n</td><td>\n\nGlideElementDynamicAttribute object containing the specified dynamic attribute.If the **fullPath** parameter is invalid, returns null.\n\n</td></tr></tbody>\n</table>The following code example shows how to call this method.\n\n```\nvar gr_Inc = new GlideRecord('incident');\ngr_Inc.get('number', 'INC0009009');\ngr_Inc.getDynamicAttribute('attr_store->color').setValue('Blue');\ngr_Inc.update();\n\ngr_Inc = new GlideRecord('incident');\ngr_Inc.get('number', 'INC0009009');\ngs.info(gr_Inc.getDynamicAttribute('attr_store', 'color'));\n```\n\nOutput:\n\n```\n*** Script: Blue\n```\n\n## GlideRecord - getDynamicAttribute\\(String dynamicAttributeField, String attrPath\\)\n\nReturns a GlideElementDynamicAttribute object that contains the dynamic attribute located at the specified table field and attribute path.\n\nDynamic attributes have a defined data type and a sys\\_id. For more details on dynamic attributes, see [Dynamic schema](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/dynamic-schema.md).\n\nSee also:\n\n-   [GlideDynamicAttribute - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideDynamicAttributeAPI.md)\n-   [GlideDynamicAttributeStore - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideDynamicAttStoreAPI.md)\n-   [GlideDynamicNamespace - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideDynamicNamespaceAPI.md)\n\n<table id=\"table_yzz_p1x_1bc\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\ndynamicAttributeField\n\n</td><td>\n\nString\n\n</td><td id=\"DynS-dynamicAttributeField-entry\">\n\nName of the field in the table that contains the dynamic attribute.\n\n</td></tr><tr><td>\n\nattrPath\n\n</td><td>\n\nString\n\n</td><td>\n\nAttribute path to use to locate the associated dynamic schema attribute.Format: `\"attr_name\"`\n\n`attr_name`: Name of the dynamic attribute.\n\nTable: In the attribute field of the Dynamic Attribute \\[dynamic\\_attribute\\] table.\n\n</td></tr></tbody>\n</table><table id=\"table_zzz_p1x_1bc\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nObject\n\n</td><td>\n\nGlideElementDynamicAttribute object containing the specified dynamic attribute.If either the **dynamicAttributeField** or **attrPath** parameters are invalid, returns null.\n\n</td></tr></tbody>\n</table>The following code example shows how to call this method.\n\n```\nvar gr_Inc = new GlideRecord('incident');\ngr_Inc.get('number', 'INC0009009');\ngr_Inc.getDynamicAttribute('attr_store', 'color').setValue('Blue');\ngr_Inc.update();\n\ngr_Inc = new GlideRecord('incident');\ngr_Inc.get('number', 'INC0009009');\ngs.info(gr_Inc.getDynamicAttribute('attr_store', 'color'));\n```\n\nOutput:\n\n```\n*** Script: Blue\n```\n\n## GlideRecord - getDynamicAttributeValue\\(String fullPath\\)\n\nReturns the value of the dynamic attribute located at a specified path.\n\nDynamic attributes have a defined data type and a sys\\_id. For more details on dynamic attributes, see [Dynamic schema](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/dynamic-schema.md).\n\nSee also:\n\n-   [GlideDynamicAttribute - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideDynamicAttributeAPI.md)\n-   [GlideDynamicAttributeStore - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideDynamicAttStoreAPI.md)\n-   [GlideDynamicNamespace - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideDynamicNamespaceAPI.md)\n\n<table id=\"table_oh3_x1x_1bc\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nfullPath\n\n</td><td>\n\nString\n\n</td><td>\n\nPath to use to locate the desired dynamic attribute. Format of the attribute path: `dyn_att_field->attr_name`\n\n-   `dyn_att_field`: Name of a dynamic attribute store field on the table.\n-   `attr_name`: Name of the dynamic attribute.\n\nTable: Dynamic Attribute \\[dynamic\\_attribute\\]\n\n\nSee also [Dynamic Schema](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/dynamic-schema.md).\n\n</td></tr></tbody>\n</table><table id=\"table_ph3_x1x_1bc\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nObject\n\n</td><td>\n\nValue of the dynamic attribute located at the specified path.If the **fullPath** parameter contains invalid data or the specified attribute value isn't one of the supported data types, returns null.\n\n</td></tr></tbody>\n</table>The following code example shows how to call this method.\n\n```\n// Update the value of the attribute 'attribute_store->time_of_purchase' incident 'INC0009009' to a timestamp (in UTC)\nvar gr1 = new GlideRecord('incident');\ngr1.get('number', 'INC0009009');\ngr1.setDynamicAttributeValue('attribute_store->time_of_purchase', '2020-05-13 13:52:44');\ngr1.update();\n\n// Then retrieve the value of the attribute on the same record\nvar gr2 = new GlideRecord('incident');\ngr2.get('number', 'INC0009009');\ngs.info(\"Time of Purchase Value        (UTC): \" + gr2.getDynamicAttributeValue('attribute_store->time_of_purchase'));\ngs.info(\"Time of Purchase DisplayValue (PST): \" + gr2.getDynamicAttributeDisplayValue('attribute_store->time_of_purchase'));\n```\n\nOutput:\n\n```\n*** Script: Time of Purchase Value        (UTC): 2020-05-13 13:52:44\n*** Script: Time of Purchase DisplayValue (PST): 2020-05-13 06:52:44\n```\n\n## GlideRecord - getDynamicAttributeValue\\(String dynamicAttributeField, String attrPath\\)\n\nReturns the value of the dynamic attribute located at a specified field in the current table and a specified attribute path.\n\nDynamic attributes have a defined data type and a sys\\_id. For more details on dynamic attributes, see [Dynamic schema](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/dynamic-schema.md).\n\nSee also:\n\n-   [GlideDynamicAttribute - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideDynamicAttributeAPI.md)\n-   [GlideDynamicAttributeStore - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideDynamicAttStoreAPI.md)\n-   [GlideDynamicNamespace - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideDynamicNamespaceAPI.md)\n\n<table id=\"table_n1f_fbx_1bc\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\ndynamicAttributeField\n\n</td><td>\n\nString\n\n</td><td id=\"DynS-dynamicAttributeField-entry\">\n\nName of the field in the table that contains the dynamic attribute.\n\n</td></tr><tr><td>\n\nattrPath\n\n</td><td>\n\nString\n\n</td><td>\n\nAttribute path to use to locate the associated dynamic schema attribute.Format: `\"attr_name\"`\n\n`attr_name`: Name of the dynamic attribute.\n\nTable: In the attribute field of the Dynamic Attribute \\[dynamic\\_attribute\\] table.\n\n</td></tr></tbody>\n</table><table id=\"table_o1f_fbx_1bc\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nObject\n\n</td><td>\n\nValue of the dynamic attribute located at the specified path.If either the **dynamicAttributeField** or **attrPath** parameters are invalid, returns null.\n\n</td></tr></tbody>\n</table>The following code example shows how to call this method.\n\n```\n// Update the value of the attribute 'attribute_store->time_of_purchase' incident `INC0009009` to a timestamp (in UTC)\nvar gr1 = new GlideRecord('incident');\ngr1.get('number', 'INC0009009');\ngr1.setDynamicAttributeValue('attribute_store', 'time_of_purchase', '2020-05-13 13:52:44');\ngr1.update();\n\n// Then retrieve the value of the attribute on the same record\nvar gr2 = new GlideRecord('incident');\ngr2.get('number', 'INC0009009');\ngs.info(\"Time of Purchase Value        (UTC): \" + gr2.getDynamicAttributeValue('attribute_store', 'time_of_purchase'));\ngs.info(\"Time of Purchase DisplayValue (PST): \" + gr2.getDynamicAttributeDisplayValue('attribute_store', 'time_of_purchase'));\n```\n\nOutput:\n\n```\n*** Script: Time of Purchase Value        (UTC): 2020-05-13 13:52:44\n*** Script: Time of Purchase DisplayValue (PST): 2020-05-13 06:52:44\n```\n\n## GlideRecord - getDynamicAttributeDisplayValue\\(String fullPath\\)\n\nReturns the display value of the dynamic attribute located at the specified path.\n\nDynamic attributes have a defined data type and a sys\\_id. For more details on dynamic attributes, see [Dynamic schema](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/dynamic-schema.md).\n\nSee also:\n\n-   [GlideDynamicAttribute - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideDynamicAttributeAPI.md)\n-   [GlideDynamicAttributeStore - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideDynamicAttStoreAPI.md)\n-   [GlideDynamicNamespace - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideDynamicNamespaceAPI.md)\n\n<table id=\"table_nht_nbx_1bc\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nfullPath\n\n</td><td>\n\nString\n\n</td><td>\n\nPath to use to locate the desired dynamic attribute. Format of the attribute path: `dyn_att_field->attr_name`\n\n-   `dyn_att_field`: Name of a dynamic attribute store field on the table.\n-   `attr_name`: Name of the dynamic attribute.\n\nTable: Dynamic Attribute \\[dynamic\\_attribute\\]\n\n\nSee also [Dynamic Schema](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/dynamic-schema.md).\n\n</td></tr></tbody>\n</table><table id=\"table_oht_nbx_1bc\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nString\n\n</td><td>\n\nDisplay value of the dynamic attribute located at the specified path.If the **fullPath** parameter is invalid, returns null.\n\n</td></tr></tbody>\n</table>The following code example shows how to call this method.\n\n```\n// Update the value of the attribute 'attribute_store->time_of_purchase' incident INC0009009 to a timestamp (in UTC)\nvar gr1 = new GlideRecord('incident');\ngr1.get('number', 'INC0009009');\ngr1.setDynamicAttributeValue('attribute_store->time_of_purchase', '2020-05-13 13:52:44');\ngr1.update();\n\n// Then retrieve the value of the attribute on the same record\nvar gr2 = new GlideRecord('incident');\ngr2.get('number', 'INC0009009');\ngs.info(\"Time of Purchase Value        (UTC): \" + gr2.getDynamicAttributeValue('attribute_store->time_of_purchase'));\ngs.info(\"Time of Purchase DisplayValue (PST): \" + gr2.getDynamicAttributeDisplayValue('attribute_store->time_of_purchase'));\n```\n\nOutput:\n\n```\n*** Script: Time of Purchase Value        (UTC): 2020-05-13 13:52:44\n*** Script: Time of Purchase DisplayValue (PST): 2020-05-13 06:52:44\n```\n\n## GlideRecord - getDynamicAttributeDisplayValue\\(String dynamicAttributeField, String attrPath\\)\n\nReturns the display value of the dynamic attribute located in a specified table field and attribute path.\n\nDynamic attributes have a defined data type and a sys\\_id. For more details on dynamic attributes, see [Dynamic schema](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/dynamic-schema.md).\n\nSee also:\n\n-   [GlideDynamicAttribute - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideDynamicAttributeAPI.md)\n-   [GlideDynamicAttributeStore - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideDynamicAttStoreAPI.md)\n-   [GlideDynamicNamespace - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideDynamicNamespaceAPI.md)\n\n<table id=\"table_vm3_wbx_1bc\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\ndynamicAttributeField\n\n</td><td>\n\nString\n\n</td><td id=\"DynS-dynamicAttributeField-entry\">\n\nName of the field in the table that contains the dynamic attribute.\n\n</td></tr><tr><td>\n\nattrPath\n\n</td><td>\n\nString\n\n</td><td>\n\nAttribute path to use to locate the associated dynamic schema attribute.Format: `\"attr_name\"`\n\n`attr_name`: Name of the dynamic attribute.\n\nTable: In the attribute field of the Dynamic Attribute \\[dynamic\\_attribute\\] table.\n\n</td></tr></tbody>\n</table><table id=\"table_wm3_wbx_1bc\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nString\n\n</td><td>\n\nDisplay value of the dynamic attribute located at the specified path.If either the **dynamicAttributeField** or **attrPath** parameters are invalid, returns null.\n\n</td></tr></tbody>\n</table>The following code example shows how to call this method.\n\n```\n// Update the value of the attribute 'attribute_store->time_of_purchase' incident INC0009009 to a timestamp (in UTC)\nvar gr1 = new GlideRecord('incident');\ngr1.get('number', 'INC0009009');\ngr1.setDynamicAttributeValue('attribute_store', 'time_of_purchase', '2020-05-13 13:52:44');\ngr1.update();\n\n// Then retrieve the value of the attribute on the same record\nvar gr2 = new GlideRecord('incident');\ngr2.get('number', 'INC0009009');\ngs.info(\"Time of Purchase Value        (UTC): \" + gr2.getDynamicAttributeValue('attribute_store', 'time_of_purchase'));\ngs.info(\"Time of Purchase DisplayValue (PST): \" + gr2.getDynamicAttributeDisplayValue('attribute_store', 'time_of_purchase'));\n```\n\nOutput:\n\n```\n*** Script: Time of Purchase Value        (UTC): 2020-05-13 13:52:44\n*** Script: Time of Purchase DisplayValue (PST): 2020-05-13 06:52:44\n```\n\n## GlideRecord - getED\\(\\)\n\nReturns the element's descriptor.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|GlideElementDescriptor|The element's descriptor.|\n\nThis example shows how to retrieve the name field for an incident GlideRecord.\n\n```\ngrInc = new GlideRecord('incident');\ngrInc.getActiveQuery();\ngrInc.query();\nif (grInc.next())\n  gs.info(\"Table Descriptor is - \" + grInc.getED().getName());\n\n```\n\nOutput:\n\n```\nTable Descriptor is - incident\n```\n\n### Scoped equivalent\n\nTo use the getED\\(\\) method in a scoped application, use the corresponding scoped method: [getED\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - getElement\\(String fieldName\\)\n\nRetrieves the GlideElement for a specified field.\n\nThe value returned by this method is a complete GlideElement object. The results are the equivalent of dot-walking a field value. For example, `now_GR.getElement('short_description')` provides the same result as `nowGR.short_description`.\n\nIn most cases, don’t use dot-walking to get values from a record. Dot-walking retrieves the entire object instead of the field value. Retrieving the object uses more storage and might cause undesirable results when used in arrays or in Service Portal.\n\nInstead of retrieving the entire object, you can use one of the following methods to copy the field values:\n\n-   [getValue\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md)\n-   [getDisplayValue\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md)\n\nIf dot-walking through a GlideElement object is necessary, use the toString\\(\\) method to retrieve values. For example, you might need the current caller's manager sys\\_id to set another reference field. The following example shows how to get the string value instead of the entire object:\n\n```\nvar mgr = current.caller_id.manager.toString();\n```\n\nSee also: [GlideElement - toString\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideElementAPI.md).\n\n|Name|Type|Description|\n|----|----|-----------|\n|fieldName|String|Column name for which to return the GlideElement object.|\n\n|Type|Description|\n|----|-----------|\n|GlideElement|The GlideElement for the specified column of the current record. Each object describes a field in the current GlideRecord.|\n\nThis example shows how to obtain the GlideElement object for a passed in table and compare them with the expected system metadata values.\n\n```\nfunction compareElement(comment, table, element, /*{}*/ expected) {\n  var now_GR = new GlideRecord(table);\n  var el = now_GR.getElement(element);\n  for (var n in expected) {\n    assertEquals(comment + \":\" + table + \".\" + element, expected[n], el.sys_meta[n]);\n  }\n}\n```\n\n### Scoped equivalent\n\nTo use the getElement\\(\\) method in a scoped application, use the corresponding scoped method: [getElement\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - getEncodedQuery\\(\\)\n\nRetrieves the query condition of the current result set as an encoded query string.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|An [encoded query string](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-user-interface/c_EncodedQueryStrings.md).|\n\nThis example shows how to obtain the current encoded query to use later to create a read ACL role.\n\n```\nfunction createAcl(table, role) {\n  gs.print(\"Checking security on table \" + table);\n  var now_GR = new GlideRecord(\"sys_security_acl\");\n  now_GR.addQuery(\"name\", table);\n  now_GR.addQuery(\"operation\", \"read\");\n  now_GR.query();\n  var encQuery = now_GR.getEncodedQuery();\n  if (now_GR.next()) {\n    // existing acl found so use it\n    createAclRole(now_GR.sys_id.toString(), role);\n   return;\n  } else {\n    now_GR.initialize();\n    now_GR.applyEncodedQuery(encQuery);\n    var acl = now_GR.insert();\n    gs.print(\"   Added read access control on \" + table);\n    createAclRole(acl, role);\n  }\n}\n```\n\n### Scoped equivalent\n\nTo use the getEncodedQuery\\(\\) method in a scoped application, use the corresponding scoped method: [getEncodedQuery\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - getEscapedDisplayValue\\(\\)\n\nRetrieves the field value for the display field of the current record and adds escape characters for use in Jelly scripts.\n\n**Note:** For this method to work, a display value must have been set on the associated table. For information on how to do this, see [Select a field as the table display value](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/t_SelectTheDisplayValue.md).\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|Escaped value of the current table's display field.|\n\nThis example shows how to obtain the user\\_name escaped display value from the User \\[sys\\_user\\] table.\n\n```\nvar userName = \"Michael J'ones\";\nvar now_GR = new GlideRecord(\"sys_user\");\nif (now_GR.get(\"user_name\", userName)) {\n  gs.print(\"Deleting existing user=\" + userName);\n  now_GR.deleteRecord();\n}\nnow_GR.initialize();\n\nvar name = userName.split(\" \", 2);\nvar firstName = name[0];\nvar lastName = name[1];\nnow_GR.setValue(\"user_name\", userName);\ngs.print(\"Name: \" + now_GR.getValue(\"user_name\"));\nnow_GR.setValue(\"first_name\", firstName);\nnow_GR.setValue(\"last_name\", lastName);\nvar escapeValue = now_GR.getEscapedDisplayValue();\ngs.print(\"Escaped name: \" + escapeValue);\n```\n\nOutput:\n\n```\nName: Michael J'ones\nEscaped name: Michael J\\'ones\n```\n\n## GlideRecord - getFields\\(\\)\n\nRetrieves a Java ArrayList of fields in the current record.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|Java ArrayList|Fields in the current record|\n\n```\n// This can be run in \"Scripts - Background\" for demonstration purposes\n \n// Get a single incident record\nvar grINC = new GlideRecord('incident');\ngrINC.query();\ngrINC.next();\ngs.print('Using ' + grINC.getValue('number'));\ngs.print('');\n \n// getFields() returns a Java ArrayList\nvar fields = grINC.getFields();\n \n// Enumerate GlideElements in the GlideRecord object that have values\ngs.print('Enumerating over all fields with values:');\nfor (var i = 0; i < fields.size(); i++) {\n  var glideElement = fields.get(i);\n  if (glideElement.hasValue()) {\n    gs.print('  ' + glideElement.getName() + '\\t' + glideElement);\n  }\n}\ngs.print('');\n \n// Get a specific GlideElement: number\ngs.print('Getting the number field:');\nfor (var i = 0; i < fields.size(); i++) {\n  var glideElement = fields.get(i);\n  if (glideElement.hasValue() && glideElement.getName() == 'number') {\n    gs.print('  ' + glideElement.getName() + '\\t' + glideElement);\n  }\n}\n```\n\n## GlideRecord - getLabel\\(\\)\n\nRetrieves the field's label.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|The field's label|\n\nThis example shows how to retrieve a label of a question field in the Requested Item table and print the label and its display name.\n\n```\ntemplate.print(\"Summary of Requested items:\\n\");  \nvar now_GR = new GlideRecord(\"sc_req_item\");\nnow_GR.addQuery(\"request\", current.sysapproval);\nnow_GR.query();\nwhile(now_GR.next()) {\nvar nicePrice = now_GR.price.toString();\n    if (nicePrice != '') {\n        nicePrice = parseFloat(nicePrice);\n        nicePrice = nicePrice.toFixed(2);\n    }\n    template.print(now_GR.number + \":  \" + now_GR.quantity + \" X \" + now_GR.cat_item.getDisplayValue() \n                     + \" at $\" + nicePrice + \" each \\n\");\n    template.print(\"    Options:\\n\");\n    for (key in now_GR.variables) {\n    var now_V = now_GR.variables[key];\n      if(now_V.getGlideObject().getQuestion().getLabel() != '') {\n         template.space(4);\n         template.print('     ' + now_V.getGlideObject().getQuestion().getLabel() + \" = \" \n                     + vnow_V.getDisplayValue() + \"\\n\");  \n      }\n    }\n}\n```\n\n### Scoped equivalent\n\nTo use the getLabel\\(\\) method in a scoped application, use the corresponding scoped method: [getLabel\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - getLink\\(Boolean noStack\\)\n\nRetrieves the link for the current record.\n\n<table id=\"table_evz_2hr_dt\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nnoStack\n\n</td><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether to append the generated link to the end of the URL. For example: `&sysparm_stack=[tablename]_list.do? sysparm_query=active=true`.Valid values:\n\n-   true: Append link.\n-   false: Do not append link.\n\n Default: false\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|String|URL of the current record.|\n\nThis example checks for attachments and adds the link if any are found.\n\n```\nvar attachment_link = '';\nvar rec = new GlideRecord('sc_req_item');\nrec.addQuery('sys_id', current.request_item);\nrec.query();\nif(rec.next()){\n  if(rec.hasAttachments()){\n    attachment_link = gs.getProperty('glide.servlet.uri') + rec.getLink();\n  }   \n}\n```\n\n### Scoped equivalent\n\nTo use the getLink\\(\\) method in a scoped application, use the corresponding scoped method: [getLink\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - getLocation\\(\\)\n\nRetrieves the row number of the current record within the table.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|Number|Zero-based row number of the current record within the table.|\n\nThis example shows how to check if a record within the Incident table is not retrieved properly by comparing the record count to the record location number.\n\n```\nvar now_GR = new GlideRecord(\"incident\");\nnow_GR.addQuery(\"priority\", \"4\");\nnow_GR.query();\nfor (x=0; x <4; x++) {\n  now_GR.next();\n  gs.print(\"Location value: \" + now_GR.getLocation());\n}\n```\n\nOutput:\n\n```\nLocation value: 0\nLocation value: 1\nLocation value: 2\nLocation value: 3\n```\n\n## GlideRecord - getPlural\\(\\)\n\nRetrieves the plural label of the GlideRecord table.\n\nFor example, if the table name is \"Change Request,\" this method returns \"Change Requests.\"\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|The plural label of the GlideRecord's table.|\n\nThis example shows checks the return values for getLabel\\(\\) and getPlural\\(\\) for the Incident table.\n\n```\nvar now_GR = new GlideRecord('incident');\ngs.print(now_GR.getLabel());\nif (now_GR.getLabel() != 'Incident')\nthrow \"GlideRecord.getLabel() returned unexpected value for table 'incident': \" + now_GR.getLabel();\n\ngs.print(now_GR.getPlural());\nif (now_GR.getPlural() != 'Incidents')\nthrow \"GlideRecord.getPlural() returned unexpected value for table 'incident': \" + now_GR.getPlural();\n\"success\";\n```\n\n### Scoped equivalent\n\nTo use the getPlural\\(\\) method in a scoped application, use the scoped [GlideRecord.getED\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md) method to obtain the field's descriptor, and then use the scoped [GlideElementDescriptor.getPlural\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideElementDescriptorScopedAPI.md) method.\n\n## GlideRecord - getRecordClassName\\(\\)\n\nRetrieves the class \\(table\\) name for the current record.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|Class or table name|\n\n```\nfunction TaskAssignmentFilter() {\n  var classname = current.getRecordClassName();\n  var filter = \"type=null\";\n  if (classname == \"incident\" && current.category == \"database\") {\n    filter = GetGroupFilter(\"database\");\n  }\n  else {\n    // append exclusion for 'catalog' to the filter\n    var cat = new GlideRecord(\"sys_user_group_type\");  \n    cat.addQuery(\"name\", \"catalog\");\n    cat.query();\n    if (cat.next()) {\n      filter += \"^ORtype!=\" + cat.sys_id;\n    }\n  }\n  gs.log(\"TaskAssignmentFilter: \" + filter);\n  return filter;\n}\n```\n\n### Scoped equivalent\n\nTo use the getRecordClassName\\(\\) method in a scoped application, use the corresponding scoped method: [getRecordClassName\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - getRelatedLists\\(\\)\n\nRetrieves a list of names and display values of related lists associated with the current GlideRecord.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|HashMap|Hash map with names and display values of related lists.|\n\nThis example shows how to obtain the list of names and display values of related lists associated with the current GlideRecord, store them in an array, and then print their values.\n\n```\nvar now_GR = new GlideRecord('incident');\nvar c = now_GR.getRelatedLists().values().toArray();\nvar numElements = c.length;\nfor( var i = 0; i < numElements; ++i){\n  gs.print(i+\": \"+c[i]);\n}\n```\n\n## GlideRecord - getRelatedTables\\(\\)\n\nRetrieves a list of names and display values of tables that are referred to by the current record.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|HashMap|Hash map with names and display values of related tables.|\n\nThis example shows how to obtain the list of names and display values of tables related to the current GlideRecord, store them in an array, and then print their values.\n\n```\nvar now_GR = new GlideRecord('incident');\nvar c = now_GR.getRelatedTables().values().toArray();\nvar numElements = c.length;\nfor( var i = 0; i < numElements; ++i){\n  gs.print(i+\": \"+c[i]);\n}\n```\n\n## GlideRecord - getRowCount\\(\\)\n\nRetrieves the number of rows \\(records\\) in the current GlideRecord object.\n\n**Note:** GlideRecord returns matching records, so it might not be as efficient as GlideAggregate when you only need the number of records. If you only need a record count and aren’t iterating over the matching records, use GlideAggregate.\n\n-   **Retrieving the number of records in GlideRecord or GlideAggregate**\n\n    The GlideRecord getRowCount\\(\\) and [GlideAggregate getAggregate\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideAggregateScopedAPI.md) APIs offer similar information. Use the following criteria to determine which option is best for you.\n\n    -   The GlideRecord getRowCount\\(\\) method tells you how many records have been returned from a query along with the records themselves. If you need the number of records in the result set before or after you iterate over the set to perform actions on the records, use this method.\n    -   The GlideAggregate getAggregate\\(\\) method retrieves only a count of records matching the query, excluding the actual records. The aggregate must be set on the GlideAggregate object before issuing the query.\n    Retrieving the records and count with GlideRecord getRowCount\\(\\)\n\n    The following example shows how to get the total number of active incidents with GlideRecord getRowCount\\(\\):\n\n    ```\n    var incident = new GlideRecord(\"incident\");\n    incident.addQuery(\"active\", true);\n    incident.query();\n     \n    gs.info(\"*** Total number of active incidents: {0}\", incident.getRowCount());\n    ```\n\n    Retrieving only the number of records with GlideAggregate getAggregate\\(\\)\n\n    The following example shows how to return only the number of records. Because this method doesn’t use the matching records, it’s much more efficient to use an aggregate query and return just the count.\n\n    ```\n    var incident = new GlideAggregate(\"incident\");\n    incident.addQuery(\"active\", true);\n    incident.addAggregate(\"COUNT\");\n    incident.query();\n     \n    if (incident.next())\n        gs.info(\"*** Total number of active incidents: {0}\", incident.getAggregate(\"COUNT\"));\n    ```\n\n    Deciding which option is best for your solution\n\n    If you only want to retrieve the number of records, the GlideAggregate getAggregate\\(\\) method is the best option. To use the individual records and retrieve the number of results, use GlideRecord getRowCount\\(\\), because a single query provides this functionality.\n\n\n**Note:** If you want to use the getRowCount\\(\\) method when using `sys_id IN` with more than 100 sys\\_id values, such as `grIncident.addQuery('sys_id', 'IN', listOf200SysIds)`, you must either:\n\n-   Call the disableSysIdInOptimization\\(\\) method on the GlideRecord.\n-   Or, adjust the **glide.db.first\\_pass\\_sys\\_id\\_list\\_size.max** system property to a value higher than the number of sys\\_ids in the list.\n\nIn addition, ensure that you call the .next\\(\\) method before calling the getRowCount\\(\\) method.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|Number|Number of rows in the current GlideRecord.|\n\nThe following example shows how to get the number of incidents from the Incident \\[incident\\] table.\n\n```\nvar numberOfIncidents = new GlideRecord('incident');\nnumberOfIncidents.query();\ngs.info(\"Records in incident table: \" + numberOfIncidents.getRowCount());\n```\n\nOutput:\n\n```\nRecords in incident table: 6920\n```\n\nThe following code example shows how to use the disableSysIdInOptimiation\\(\\) method to disable the sys\\_id limit optimization when passing an Incident sys\\_id list that contains 200 entries.\n\n```\nvar listOf200SysIds = [ ... ]; // 200 comma separated sys_ids\nvar grIncident = new GlideRecord('incident');\ngrIncident.addQuery('sys_id', 'IN', listOf200SysIds);\ngrIncident.disableSysIdInOptimization(); // Rowcount could be incorrect without this method call\ngrIncident.query();\nif (grIncident.next())\n    gs.info(\"Rowcount: \" + grIncident.getRowCount());\n```\n\nOutput:\n\n```\nRowcount: 200\n```\n\n### Scoped equivalent\n\nTo use the getRowCount\\(\\) method in a scoped application, use the corresponding scoped method: [getRowCount\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - getRowNumber\\(\\)\n\nRetrieves the row number set by saveLocation\\(\\) or setLocation\\(\\).\n\nTo get the current row number, use getLocation\\(\\).\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|Number|Saved row number.|\n\nThis example shows how to save a row location in the Users table and then obtain that row number.\n\n```\nvar now_GR = new GlideRecord('sys_user');\nnow_GR.addQuery();\nnow_GR.query();\nnow_GR.saveLocation(5);\nvar savedRow = now_GR.getRowNumber();\ngs.print(\"Saved row: \" + savedRow);\n```\n\nOutput:\n\n```\nSaved row: 5\n```\n\n## GlideRecord - getTableName\\(\\)\n\nRetrieves the table name associated with this GlideRecord.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|A table name|\n\nThis example shows how to write the current table name in the system log.\n\n```\ngs.log('Table: ' + current.getTableName()); \ngs.log('Parent: ' + current.parent.sys_id); \nvar item = new GlideRecord('sc_req_item'); \nitem.addQuery('sys_id', current.parent.sys_id); \nitem.query(); \nif(item.next()){ \n  for(var variable in item.variable_pool) {\n    gs.log(variable); \n    var answer = eval (\"item.variable_pool.\" + variable + \".getDisplayValue()\");\n    gs.log(answer);\n  }\n}\n```\n\n### Scoped equivalent\n\nTo use the getTableName\\(\\) method in a scoped application, use the corresponding scoped method: [getTableName\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - getUniqueValue\\(\\)\n\nGets the primary key of the record, which is usually the sys\\_id unless otherwise specified.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|The unique primary key as a String, or null if the key is null.|\n\n```\nvar now_GR = new GlideRecord('kb_knowledge');\nnow_GR.query();\nnow_GR.next();\nvar uniqueid = now_GR.getUniqueValue();\ngs.info(uniqueid);\n```\n\n## GlideRecord - getValue\\(String fieldName\\)\n\nRetrieves the string value of a specified field or the string value of an attribute in a dynamic attribute store.\n\n**Note:** If the Field Encryption Enterprise plugin is enabled and the instance has access to the key, this method returns clear text values from encrypted fields. If the instance does not have access to the key, this method returns the encrypted value. For more information, see [Platform Encryption](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-security/encryption-landing.md).\n\nSee also [Dynamic Schema](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/dynamic-schema.md).\n\n<table id=\"table_ev2_flr_dt\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nfieldName\n\n</td><td>\n\nString\n\n</td><td>\n\nThe name of the field whose value you want to retrieve or the path to an attribute within a dynamic attribute store to retrieve.Format of the attribute path: `dyn_att_field->attr_name`\n\n-   `dyn_att_field`: Name of a dynamic attribute store field on the table.\n-   `attr_name`: Name of the dynamic attribute.\n\nTable: Dynamic Attribute \\[dynamic\\_attribute\\]\n\n\nSee also [Dynamic Schema](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/dynamic-schema.md).\n\n</td></tr></tbody>\n</table><table id=\"table_fv2_flr_dt\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nString\n\n</td><td>\n\nValue of the specified element. Returns null if the field is empty or the field doesn't exist. **Note:** Boolean values return as `\"0\"` and `\"1\"` string values instead of false and true.\n\n</td></tr></tbody>\n</table>This example uses the getValue\\(\\) method to obtain field values in two GlideRecords that are being compared.\n\n```\nfunction() {\n  var jobExists = true;\n  var jobGr;\n  while(jobExists){\n    jobGr = new GlideRecord(\"sys_trigger\");\n    jobExists = jobGr.get(\"name\", \"BaselineAPI: Create Baseline Job\");\n  }\n  var baselineGr =  new GlideRecord('pm_project_baseline');\n  baselineGr.get('baseline_name','Test Project Baseline');\n  baselineGr.query();\n \n  Assert.assertEquals(true, baselineGr.next());\n  var projectGr =  new GlideRecord('pm_project');\n  projectGr.get(this._project);\n  Assert.assertEquals(projectGr.getValue('cost'), baselineGr.getValue('cost'));\n  Assert.assertEquals((projectGr.getValue('capex_cost')), baselineGr.getValue('capex_cost'));\n  Assert.assertEquals((projectGr.getValue('opex_cost')), baselineGr.getValue('opex_cost'));\n  Assert.assertEquals((projectGr.getValue('budget_cost')), baselineGr.getValue('budget_cost'));\n  Assert.assertEquals((projectGr.getValue('value')), baselineGr.getValue('value'));\n  Assert.assertEquals((projectGr.getValue('npv_value')), baselineGr.getValue('npv_value'));  Assert.assertEquals((projectGr.getValue('score')), baselineGr.getValue('score'));\n}\n```\n\nThis example shows how to retrieve the value of a dynamic attribute.\n\n```\n// Update the value of the attribute 'attribute_store->color' to 'Red' on incident INC0009009\nvar gr1 = new GlideRecord('incident');\ngr1.get('number', 'INC0009009');\ngr1.setDynamicAttributeValue('attribute_store->color', 'Red');\ngr1.update();\n\n// Then retrieve the value of the attribute on the same record\nvar gr2 = new GlideRecord('incident');\ngr2.get('number', 'INC0009009');\ngs.info(gr2.getValue('attribute_store->color'));\n```\n\nOutput:\n\n```\n*** Script: Red\n```\n\n### Scoped equivalent\n\nTo use the getValue\\(\\) method in a scoped application, use the corresponding scoped method: [getValue\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - hasAttachments\\(\\)\n\nDetermines if the current GlideRecord has any attachments.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|Boolean|True if the current record has attachments, false otherwise.|\n\nThis example checks for attachments and creates a link if there are any.\n\n```\nvar attachment_link = '';\nvar rec = new GlideRecord('sc_req_item');\nrec.addQuery('sys_id', current.request_item);\nrec.query();\nif(rec.next()){\n  if(rec.hasAttachments()){\n    attachment_link = gs.getProperty('glide.servlet.uri') + rec.getLink();\n  }   \n}\n```\n\n## GlideRecord - hasNext\\(\\)\n\nDetermines if there are any more records in the GlideRecord.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|Boolean|True if there are more records in the query set, otherwise false.|\n\nThis example shows how to call different functions based on whether there are additional records in the current GlideRecord.\n\n```\nif (now_GR.hasNext()) {\n  dothis(); // found it, do it\n} else {\n  dothat(); // didn't find it\n};\n```\n\n### Scoped equivalent\n\nTo use the hasNext\\(\\) method in a scoped application, use the corresponding scoped method: [hasNext\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - initialize\\(\\)\n\nCreates an empty record within the current GlideRecord that is suitable for population before an insert.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|void| |\n\nThis example initializes a new record in the to\\_do table, creates a record, and then inserts it into the table.\n\n```\nvar now_GR = new GlideRecord('to_do');\nnow_GR.initialize(); \nnow_GR.name = 'first to do item'; \nnow_GR.description = 'learn about GlideRecord'; \nnow_GR.insert();\n```\n\n### Scoped equivalent\n\nTo use the initialize\\(\\) method in a scoped application, use the corresponding scoped method: [initialize\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - insert\\(\\)\n\nInserts a new record with the field values that have been set for the current record.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|The sys\\_id of the inserted record, or null if the record is not inserted.|\n\nThis example creates a new record in the to\\_do table, sets values for some record fields, and then inserts the record into the table.\n\n```\nvar now_GR = new GlideRecord('to_do');\nnow_GR.initialize(); \nnow_GR.name = 'first to do item'; \nnow_GR.description = 'learn about GlideRecord'; \nnow_GR.insert();\n```\n\n### Scoped equivalent\n\nTo use the insert\\(\\) method in a scoped application, use the corresponding scoped method: [insert\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - insertWithReferences\\(\\)\n\nInserts a new record and also inserts or updates any related records with the provided information.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|sys\\_id of the inserted record or null if the record was not inserted.|\n\nIf a reference value is not specified \\(as below\\), then a new user record is created with the provided first\\_name and last\\_name, and the caller\\_id value is set to this newly created sys\\_user record. The result is a new sys\\_user record with the provided first\\_name and last\\_name and a new incident record with the provided short\\_description and caller\\_id.\n\n```\nvar inc = new GlideRecord('incident');\ninc.initialize();\ninc.short_description = 'New incident 1';\ninc.caller_id.first_name = 'John';\ninc.caller_id.last_name = 'Doe';\ninc.insertWithReferences();\n```\n\nIf a caller\\_id value is specified, then that caller\\_id is updated with the provided first\\_name and last\\_name. The result is a newly created incident record with values set for short\\_description and caller\\_id.\n\n```\nvar inc = new GlideRecord('incident');\ninc.initialize();\ninc.short_description = 'New incident 1';\ninc.caller_id.setDisplayValue('David Loo');\ninc.caller_id.first_name = 'John';\ninc.caller_id.last_name = 'Doe';\ninc.insertWithReferences();\n```\n\n## GlideRecord - instanceOf\\(String className\\)\n\nChecks a table for the type\\\\class of table.\n\n|Name|Type|Description|\n|----|----|-----------|\n|className|String|Name of a type or class of record.|\n\n|Type|Description|\n|----|-----------|\n|Boolean|True if table is an instance of the specified class.|\n\nThis example checks if the passed in group/user is of the sys\\_user table/class type.\n\n```\nfunction(groupOrUser, label, grantedBy) {\n  var labelCheck;\n  var labelRecord;\n  if (typeof label === \"string\") {\n    labelRecord = new GlideRecord('label');\n    labelRecord.addQuery('name', label);\n    labelRecord.query();\n    labelRecord.next();\n  } else {\n    labelRecord = label;\n  }\n  if (groupOrUser.instanceOf('sys_user')) {\n    labelCheck = new GlideRecord('label_user_m2m');\n    labelCheck.addQuery('user', groupOrUser.sys_id);\n  } else {\n    labelCheck = new GlideRecord('label_group_m2m');\n    labelCheck.addQuery('group', groupOrUser.sys_id);\n  }\n  labelCheck.addQuery('label', labelRecord.sys_id);\n  if (grantedBy !== \"undefined\") {\n    labelCheck.addQuery('granted_by', grantedBy.sys_id);\n  }\n  labelCheck.query();\n  return labelCheck.hasNext();\n}\n```\n\n## GlideRecord - isNewRecord\\(\\)\n\nDetermines whether the current record has been inserted into the database.\n\nThis method returns true only if the newRecord\\(\\) method has been called. This method is useful for scripted ACL, and in the condition of UI actions, but should not be used in background scripts.\n\n**Note:** This method returns true for any new record during a business rule, or if the newRecord\\(\\) method is used to initialize a record with default values and a unique ID \\(sys\\_id\\). In all other cases, it returns false.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n<table id=\"table_wbn_g4q_dt\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether the current record is new \\(has not been inserted into the database.\\)Possible values:\n\n-   true: Record is new.\n-   false: Record is not new.\n\n</td></tr></tbody>\n</table>This example checks if the new record has been inserted into the sys\\_user table.\n\n```\nvar now_GR = new GlideRecord(\"sys_user\");\nnow_GR.newRecord();\nnow_GR.setValue(\"user_name\", \"John Smith\");\ngs.print(\"Is this a new record: \" + now_GR.isNewRecord());\n\nvar now_GR2 = new GlideRecord(\"sys_user\");\nnow_GR2.addQuery(\"user_name\", \"Abel Tutor\");\nnow_GR2.query();\nnow_GR2.next();\ngs.print(\"Is this a new record: \" + now_GR2.isNewRecord());\n```\n\n## GlideRecord - isValid\\(\\)\n\nDetermines if the current GlideRecord table exists.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|Boolean|True if the table is exists \\(valid\\), otherwise false.|\n\nThis example checks if the Incident table exists.\n\n```\nvar testTable = new GlideRecord('incident');\ngs.print(testTable.isValid());\n```\n\n### Scoped equivalent\n\nTo use the isValid\\(\\) method in a scoped application, use the corresponding scoped method: [isValid\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - isValidField\\(String columnName\\)\n\nDetermines if the specified field is defined in the current GlideRecord table.\n\n|Name|Type|Description|\n|----|----|-----------|\n|columnName|String|Name of a column to check.|\n\n|Type|Description|\n|----|-----------|\n|Boolean|True if the field is defined in the table, otherwise false.|\n\nThis example checks if the sys\\_class\\_name field exists in the cmds\\_software\\_instance table.\n\n```\nvar gobj = new GlideRecord('sys_db_object');\ngobj.addQuery('name','cmdb_software_instance');\ngobj.query();\nif (!gobj.next()) {\n  var si = new GlideRecord('cmdb_software_instance');\n  si.query();\n  var count = 0;\n  while (si.next()) {\n    if (!si.isValidField('sys_class_name')) {\n      var ci = new GlideRecord('cmdb_ci');\n      ci.name = si.name;\n      ci.setNewGuidValue(si.sys_id);\n      ci.sys_class_name = 'cmdb_software_instance';\n      ci.insert();\n      count++;\n    }\n  }\n}\n```\n\n### Scoped equivalent\n\nTo use the isValidField\\(\\) method in a scoped application, use the corresponding scoped method: [isValidField\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - isValidRecord\\(\\)\n\nDetermines if the current record is valid.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n<table id=\"table_md5_3qq_dt\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nBoolean\n\n</td><td>\n\nFlag indicating whether the current record is valid.Valid values:\n\n-   true: Record is valid.\n-   false: Past the end of the record set.\n\n</td></tr></tbody>\n</table>This example checks if the record identifier by the passed in sys\\_id is a valid record in the idea table.\n\n```\nfunction(sysId) {\n  this.log('Inside acceptIdea sysId = ' + sysId);\n  var now_GR = new GlideRecord('idea');\n  now_GR.get(sysId);\n  this.log('now_GR.isValidRecord() = ' + now_GR.isValidRecord());\n  if(now_GR.isValidRecord()) {\n    now_GR.setValue('state', 2);\n    this.log('Updating gliderecord');\n    this.log('gliderecord table name' + now_GR.getTableName());\n    now_GR.update();\n  }\n}\n```\n\n### Scoped equivalent\n\nTo use the isValidRecord\\(\\) method in a scoped application, use the corresponding scoped method: [isValidRecord\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - newRecord\\(\\)\n\nCreates a GlideRecord, sets the default values for the fields, and assigns a unique ID to the record.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|void| |\n\nThis example checks if the new record has been inserted into the sys\\_user table.\n\n```\nvar now_GR = new GlideRecord(\"sys_user\");\nnow_GR.newRecord();\nnow_GR.setValue(\"user_name\", \"John Smith\");\ngs.print(\"Is this a new record: \" + now_GR.isNewRecord());\n\nvar now_GR2 = new GlideRecord(\"sys_user\");\nnow_GR2.addQuery(\"user_name\", \"Abel Tutor\");\nnow_GR2.query();\nnow_GR2.next();\ngs.print(\"Is this a new record: \" + now_GR2.isNewRecord());\n```\n\n### Scoped equivalent\n\nTo use the newRecord\\(\\) method in a scoped application, use the corresponding scoped method: [newRecord\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - next\\(\\)\n\nMoves to the next record in the GlideRecord.\n\nUse this method to iterate through the records returned by a GlideRecord query.\n\n**Note:** This method fails if there is a field in the table called \"next\". If that is the case, use the method [\\_next\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md).\n\n**Note:** The `if(myObj.next())` construct only processes the first record returned.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n<table id=\"table_t2n_yqq_dt\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates if there is a \"next\" record in the GlideRecord. Valid values:\n\n-   true: Move to the next record was successful.\n-   false: No more records in the result set.\n\n</td></tr></tbody>\n</table>This example shows how to iterate through the Incident table using the next\\(\\) method.\n\n```\nvar rec = new GlideRecord('incident');\nrec.query();\nwhile (rec.next()) { \n  gs.print(rec.number + ' exists');\n}\n```\n\n### Scoped equivalent\n\nTo use the next\\(\\) method in a scoped application, use the corresponding scoped method: [next\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - \\_next\\(\\)\n\nMoves to the next record in the GlideRecord. Provides the same functionality as next\\(\\), intended to be used in cases where the GlideRecord has a column named next.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|Boolean|True if there are more records in the query set.|\n\n```\nvar rec = new GlideRecord('sys_template');\nrec.query();\nwhile (rec._next()) { \n  gs.print(rec.number + ' exists');\n}\n```\n\n### Scoped equivalent\n\nTo use the \\_next\\(\\) method in a scoped application, use the corresponding scoped method: [\\_next\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - operation\\(\\)\n\nDetermines if an operation is insert, update, or delete.\n\nKnowing the operation enables using current.operation\\(\\) to make a generic business rule which can handle each operation uniquely.\n\nFor information on using the global variable current, refer to [Global variables in business rules](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/business-rules-classic/c_BusinessRules.md).\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n<table id=\"gr-operation-returns\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nString\n\n</td><td>\n\nThe current operation.Possible values:\n\n-   delete\n-   insert\n-   update\n\n</td></tr></tbody>\n</table>The following example shows how to use this method in a business rule. The operation\\(\\) method detects which operation triggered an event and performs a different action depending for update and insert operations.\n\n```\nif(current.operation() == \"update\") {\n  current.updates ++; } \nif(current.operation() == \"insert\") {\n  current.updates = 0; }\n```\n\nThis example shows how to use the operation\\(\\) method to pass the operation value into the startFlow\\(\\) method.\n\n```\nfunction createNewTransferOrder() {\n  var toGr = new GlideRecord(\"alm_transfer_order\");\n  toGr.initialize();\n  // From Stockroom - Southern California Warehouse\n  toGr.setValue('from_stockroom', fromStockroomSysId);\n  // To Stockroom - San Diego North - Pickup/Dropoff\n  toGr.setValue('to_stockroom', toStockroomSysId);\n  var transferOrder = toGr.insert();\n\n  if(toGr.get(transferOrder)){\n  // Start Transfer Order Workflow\n  var wf = new Workflow();\n  var context = wf.startFlow(toWorkflowSysId, toGr, toGr.operation(),{});\n    createNewTransferOrderLine(transferOrder);\n  } \n}\n```\n\n### Scoped equivalent\n\nTo use the operation\\(\\) method in a scoped application, use the corresponding scoped method: [operation\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - orderBy\\(String fieldName\\)\n\nSpecifies a field name, or path to an attribute within a dynamic attribute store, to use to order the query set. To order by multiple fields, call this method multiple times with different field values.\n\n**Note:** To enforce query access based on the user, use[addUserOrderBy\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md).\n\n<table id=\"table_rr5_fsq_dt\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nfieldName\n\n</td><td>\n\nString\n\n</td><td>\n\nTable field name, or path to an attribute within a dynamic attribute store, on which to order the query set.Format of the attribute path: `dyn_att_field->attr_name`\n\n-   `dyn_att_field`: Name of a dynamic attribute store field on the table.\n-   `attr_name`: Name of the dynamic attribute.\n\nTable: Dynamic Attribute \\[dynamic\\_attribute\\]\n\n\nSee also [Dynamic Schema](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/dynamic-schema.md).\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|void| |\n\nThis example shows how to order the query set by \"order\" and then by \"number\".\n\n```\nfunction UpdateProjectWBS(project) {\n  var count = 0;\n  var child = new GlideRecord('pm_project_task');\n  child.addQuery('parent', project.sys_id);\n  child.orderBy('order');\n  child.orderBy('number');\n  child.query();\n  var len = child.getRowCount().toString().length;\n  var seq = 0;\n  while (child.next()) {\n    count += UpdateProjectTaskWBS(child, 1, ++seq, len, '');\n  }\n  gs.addInfoMessage(count + ' Project Tasks updated');\n}\n```\n\nThis example shows how to order the query set by an attribute within a dynamic attribute store.\n\n```\nvar gr_Inc = new GlideRecord('incident');\ngr_Inc.orderBy('attribute_store->first_name');\ngr_Inc.query();\n\nwhile(gr_Inc.next()) {\n  gs.info(\"first_name: \" + gr_Inc.getValue('attribute_store->first_name'));\n}\n```\n\nOutput:\n\n```\n*** Script: first_name: Alejandro\n*** Script: first_name: Bertie\n*** Script: first_name: Beth\n*** Script: first_name: Bow\n*** Script: first_name: Bud\n*** Script: first_name: Carol\n*** Script: first_name: Charlie\n*** Script: first_name: Christen\n*** Script: first_name: David\n```\n\n### Scoped equivalent\n\nTo use the orderBy\\(\\) method in a scoped application, use the corresponding scoped method: [orderBy\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - orderByDesc\\(String fieldName\\)\n\nSpecifies the field, or an attribute in a dynamic attribute store, to use to order the query set in descending order.\n\n**Note:** To enforce query access based on the user, use[addUserOrderByDesc\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md).\n\n<table id=\"table_yht_ysq_dt\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nfieldName\n\n</td><td>\n\nString\n\n</td><td>\n\nTable field name, or path to an attribute within a dynamic attribute store, on which to order the query set in descending order.Format of the attribute path: `dyn_att_field->attr_name`\n\n-   `dyn_att_field`: Name of a dynamic attribute store field on the table.\n-   `attr_name`: Name of the dynamic attribute.\n\nTable: Dynamic Attribute \\[dynamic\\_attribute\\]\n\n\nSee also [Dynamic Schema](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/dynamic-schema.md).\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|void| |\n\nThis example shows how to order the query set in ascending or descending order.\n\n```\nfunction(fiscalType, orderByDesc) {\n  var now_GR = new GlideRecord('fiscal_period');\n  now_GR.addQuery('fiscal_type', fiscalType);\n  if (orderByDesc) {\n    now_GR.orderByDesc('fiscal_start_date_time');\n  } else {\n    now_GR.orderBy('fiscal_start_date_time');\n  }\n  now_GR.setLimit(1);\n  now_GR.query();\n  now_GR.next();\n  return now_GR.sys_id;\n}\n```\n\nThis example shows how to order the query set by an attribute within a dynamic attribute store.\n\n```\nvar gr_Inc = new GlideRecord('incident');\ngr_Inc.orderByDesc('attribute_store->first_name');\ngr_Inc.query();\n\nwhile(gr_Inc.next()) {\n  gs.info(\"first_name: \" + gr_Inc.getValue('attribute_store->first_name'));\n}\n```\n\nOutput:\n\n```\n\n*** Script: first_name: David\n*** Script: first_name: Christen\n*** Script: first_name: Charlie\n*** Script: first_name: Carol\n*** Script: first_name: Bud\n*** Script: first_name: Bow\n*** Script: first_name: Beth\n*** Script: first_name: Bertie\n*** Script: first_name: Alejandro\n```\n\n### Scoped equivalent\n\nTo use the orderByDesc\\(\\) method in a scoped application, use the corresponding scoped method: [orderByDesc\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - query\\(String field, String value\\)\n\nRuns a query against the table based on the filters specified in the query methods such as addQuery\\(\\) and addEncodedQuery\\(\\).\n\nThis method queries the GlideRecord table as well as any references of the table. For more information, see [Querying tables in script](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/scripts/c_UsingGlideRecordToQueryTables.md).\n\n**Note:** This method fails if there is a field in the table called \"query\". If that is the case, use the method [\\_query\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md). To run queries in a domain-separated instance, use the method [queryNoDomain\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md).\n\nSee the [GlideRecord](https://developer.servicenow.com/dev.do#!/learn/courses/utah/app_store_learnv2_scripting_utah_scripting_in_servicenow/app_store_learnv2_scripting_utah_server_side_scripting/app_store_learnv2_scripting_utah_gliderecord) article for details on building and running queries.\n\nSee also:\n\n-   [GlideAggregate - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideAggregateAPI.md)\n-   [GlideQuery\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideQueryGlobalAPI.md)\n-   [GlideQueryCondition - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideQueryConditionAPI.md)\n\n<table id=\"id_g13_kwd_lpb\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nname\n\n</td><td>\n\nString\n\n</td><td>\n\nOptional - must also specify a value parameter. Name of the field to search for the value specified in the value parameter.**Note:** This method is typically run without arguments, but you can specify a name-value pair to filter records containing the specified values. If the parameters are specified, the \"name=value\" condition is added to the query.\n\n</td></tr><tr><td>\n\nvalue\n\n</td><td>\n\nString\n\n</td><td>\n\nOptional - must also specify a field parameter. Value to search for in the specified field parameter.\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|void| |\n\nThe following example shows how to scan the System Dictionary \\[sys\\_dictionary\\] for tables with a query field.\n\n```\nvar tableArr = [];\n\nvar now_GR = new GlideRecord('sys_dictionary');\nnow_GR.addQuery('element', 'query');\nnow_GR.setLimit(6);\n\nnow_GR.query();\n\nwhile(now_GR.next()){\n   tableArr.push(now_GR.name.getValue());\n};\n\ngs.info('The following tables have a field column called \"query\":');\n\nfor (i = 0; i < tableArr.length; i++) {\n   gs.info(tableArr[i]);\n};\n```\n\nOutput:\n\n```\nThe following tables have a field column called \"query\":\ncmdb_convert_bulk_services\ncmdb_multisource_query_status\ncmdb_qb_result_base\ncmdb_qb_table_mapping\ndiscovery_probes_cim_query\nkb_feedback\n```\n\n### Scoped equivalent\n\nTo use the query\\(\\) method in a scoped application, use the corresponding scoped method: [query\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - \\_query\\(String field, String value\\)\n\nRuns a query against the table based on the filters specified in the query methods such as addQuery\\(\\) and addEncodedQuery\\(\\). This method is intended to be used on tables in which there's a column named \"query\", which might cause errors running the query\\(\\) method.\n\nThis method queries the GlideRecord table as well as any references of the table. For more information, see [Querying tables in script](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/scripts/c_UsingGlideRecordToQueryTables.md).\n\nSee the [GlideRecord](https://developer.servicenow.com/dev.do#!/learn/courses/utah/app_store_learnv2_scripting_utah_scripting_in_servicenow/app_store_learnv2_scripting_utah_server_side_scripting/app_store_learnv2_scripting_utah_gliderecord) article for details on building and running queries.\n\nSee also:\n\n-   [GlideAggregate - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideAggregateAPI.md)\n-   [GlideQuery\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideQueryGlobalAPI.md)\n-   [GlideQueryCondition - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideQueryConditionAPI.md)\n\n<table id=\"id_z1c_ptd_lpb\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nname\n\n</td><td>\n\nString\n\n</td><td>\n\nOptional - must also specify a value parameter. Name of the field to search for the value specified in the value parameter.**Note:** This method is typically run without arguments, but you can specify a name-value pair to filter records containing the specified values. If the parameters are specified, the \"name=value\" condition is added to the query.\n\n</td></tr><tr><td>\n\nvalue\n\n</td><td>\n\nString\n\n</td><td>\n\nOptional - must also specify a field parameter. Value to search for in the specified field parameter.\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|void| |\n\nThe following example shows how query the Knowledge Feedback \\[kb\\_feedback\\] table and list KB articles with comments that include Excel.\n\n```\nvar rec = new GlideRecord('kb_feedback');\nrec.addQuery('comments', 'CONTAINS', 'Excel');\nrec._query();\nwhile (rec.next()) { \n gs.info(rec.getDisplayValue('article') + \" comment: \" + rec.getValue('comments'));\n}\n```\n\nOutput:\n\n```\nKB0000005 comment: \n\t     Can you please add the version of Excel this applies to? All?\n\t\t\nKB0000005 comment: \n\t     Does this work for all Excel versions? OSX and Windows alike?\n```\n\n### Scoped equivalent\n\nTo use the \\_query\\(\\) method in a scoped application, use the corresponding scoped method: [\\_query\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - queryNoDomain\\(String field, String value\\)\n\nUsed in domain-separated instances. Similar to query\\(\\), runs the query against the table based on the filters specified by addQuery\\(\\) and addEncodedQuery\\(\\), but ignores domains.\n\nThis method queries the GlideRecord table as well as any references of the table. For more information, see [Querying tables in script](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/scripts/c_UsingGlideRecordToQueryTables.md).\n\n<table id=\"id_n1d_1jk_lpb\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nname\n\n</td><td>\n\nString\n\n</td><td>\n\nOptional - must also specify a value parameter. Name of the field to search for the value specified in the value parameter.**Note:** This method is typically run without arguments, but you can specify a name-value pair to filter records containing the specified values. If the parameters are specified, the \"name=value\" condition is added to the query.\n\n</td></tr><tr><td>\n\nvalue\n\n</td><td>\n\nString\n\n</td><td>\n\nOptional - must also specify a field parameter. Value to search for in the specified field parameter.\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|void| |\n\nThis example shows how to query the incident table for all domains.\n\n```\nvar rec = new GlideRecord('incident');\nrec.queryNoDomain();\nwhile (rec.next()) { \n gs.print(rec.number + ' exists');\n}\n```\n\n## GlideRecord - restoreLocation\\(\\)\n\nSets the current record to be the record that was saved with saveLocation\\(\\). If saveLocation\\(\\) has not been called, the current record is set to the first record of the GlideRecord.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|void| |\n\nThis example shows how save the current record location, move to the next record, and then return back to the saved location.\n\n```\nfunction() {\n  var now_GR = new GlideRecord(\"incident\");\n  now_GR.query();\n  now_GR.next();\n  var firstID = now_GR.getValue(\"sys_id\");\n  now_GR.next();\n  var restoreID = now_GR.getValue(\"sys_id\");\n  now_GR.saveLocation();\n  now_GR.next();\n  var lastID = now_GR.getValue(\"sys_id\");\n  now_GR.restoreLocation();\n  now_GR.next();\n  var thisID = now_GR.getValue(\"sys_id\");\n  var progress = \"first id=\" + firstID\n    + \"\\n\\t last id=\" + lastID\n    + \"\\n\\t saved id=\" + restoreID\n    + \"\\n\\t restored id=\" + thisID;\n  gs.print(\"Progress:\\n\\t\" + progress);\n}\n```\n\n## GlideRecord - saveLocation\\(\\)\n\nSaves the current row number so you can return to this location using the restoreLocation\\(\\) method.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|void| |\n\nThis example shows how save the current record location, move to the next record, and then return back to the saved location.\n\n```\nfunction() {\n  var now_GR = new GlideRecord(\"incident\");\n  now_GR.query();\n  now_GR.next();\n  var firstID = now_GR.getValue(\"sys_id\");\n  now_GR.next();\n  var restoreID = now_GR.getValue(\"sys_id\");\n  now_GR.saveLocation();\n  now_GR.next();\n  var lastID = now_GR.getValue(\"sys_id\");\n  now_GR.restoreLocation();\n  now_GR.next();\n  var thisID = now_GR.getValue(\"sys_id\");\n  var progress = \"first id=\" + firstID\n    + \"\\n\\t last id=\" + lastID\n    + \"\\n\\t saved id=\" + restoreID\n    + \"\\n\\t restored id=\" + thisID;\n  gs.print(\"Progress:\\n\\t\" + progress);\n}\n```\n\n## GlideRecord - setAbortAction\\(Boolean b\\)\n\nSets a flag to indicate if the next database action \\(insert, update, delete\\) is to be aborted.\n\nUse in an `onBefore` business rule to prevent the database action from being done. The business rule continues to run after setAbortAction\\(\\) is called. Calling setAbortAction\\(\\) does not stop subsequent business rules from executing. Calling this method only prevents the database action from occurring.\n\n|Name|Type|Description|\n|----|----|-----------|\n|b|Boolean|True to abort next action, or false to allow the next action.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n```\nif ((!current.u_date1.nil()) && (!current.u_date2.nil())) {\n  var start = current.u_date1.getGlideObject().getNumericValue();\n  var end = current.u_date2.getGlideObject().getNumericValue();\n  if (start > end) {\n    gs.addInfoMessage('start must be before end');\n    current.u_date1.setError('start must be before end');\n    current.setAbortAction(true);\n  }\n}\n```\n\n### Scoped equivalent\n\nTo use the setAbortAction\\(\\) method in a scoped application, use the corresponding scoped method: [setAbortAction\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - setCategory\\(String category\\)\n\nSets the query category, which determines how the query is routed to a secondary database.\n\nThis method requires the Secondary Database Pools \\[com.glide.secondary\\_db\\_pools\\] plugin. Call this method to route queries to a secondary \\(read replica\\) database based on the specified category, reducing load on the primary database. Due to replication lag, execution of a query on a read replica database may return slightly out of date results compared to executing the same query on the primary database.\n\nModifications to data are always serviced by the primary database, even if setCategory\\(\\) is used in the query. For example, a call to GlideRecord.update\\(\\) is always directed to the primary database even if the GlideRecord object has been provided with the name of a secondary database category via setCategory\\(\\).\n\nFor more information, see [KB0824441 Introduction to ServiceNow Read Replica Databases](https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0824441).\n\n<table id=\"table_bns_y1r_cjc\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\ncategory\n\n</td><td>\n\nString\n\n</td><td>\n\nName of the category to use to route the query to a secondary database.Table: Secondary Database Categories \\[sys\\_db\\_category\\]\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|None| |\n\nThis example uses the `embedded_list` category to route the query to a secondary database.\n\n```\nvar gr = new GlideRecord('task');\ngr.setCategory('embedded_list');\ngr.query();\n```\n\n### Scoped equivalent\n\nTo use the setCategory\\(\\) method in a scoped application, use the corresponding scoped method: [setCategory\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - setDisplayValue\\(String name, Object value\\)\n\nSets a specified field, or an attribute in a dynamic attribute store, to a specified display value.\n\nFor a reference field, this is the display value for the table. For a date/time, this is the time in the caller's current time zone.\n\n<table id=\"table_ijf_wgw_dt\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nname\n\n</td><td>\n\nString\n\n</td><td>\n\nName of the field on which to set the value.To set an attribute within a dynamic attribute store, provide the attribute path.\n\nFormat of the attribute path: `dyn_att_field->attr_name`\n\n-   `dyn_att_field`: Name of a dynamic attribute store field on the table.\n-   `attr_name`: Name of the dynamic attribute.\n\nTable: Dynamic Attribute \\[dynamic\\_attribute\\]\n\n\nSee also [Dynamic Schema](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/dynamic-schema.md).\n\n</td></tr><tr><td>\n\nvalue\n\n</td><td>\n\nObject\n\n</td><td id=\"DynS-value-entry\">\n\nValue to set in the specified attribute.**Note:** For dynamic attributes, only the following data types are supported:\n\n-   Boolean \\(True/False\\)\n-   Decimal\n-   Floating Point Number\n-   GlideDate\n-   GlideDateTime\n-   Integer\n-   String\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|void| |\n\nThe following code example shows how to set a display value in a record and then update the record.\n\n```\nvar now_GR = new GlideRecord('incident');\nnow_GR.get('46f09e75a9fe198100f4ffd8d366d17b');\nnow_GR.setDisplayValue('opened_at','2011-02-13 4:30:00');\nnow_GR.update();\n```\n\nThe following code example shows how to set a display value in a dynamic attribute store.\n\n```\nvar gr_AppTab = new GlideRecord('application_table'); \ngr_AppTab.setValue('dyn_att_field->attr', 42); \ngr_AppTab.setDisplayValue('dyn_att_field->attr2, true);\ngr_AppTab.update();\ngs.info('Attr value: ' + \ngr_AppTab.getDisplayValue('dyn_att_field->attr);\ngs.info('Attr2 value: ' + \ngr_AppTab.getDisplayValue('dyn_att_field->attr2);\n```\n\n## GlideRecord - setDynamicAttributeValue\\(String fullPath, Object value\\)\n\nSets the value of the dynamic attribute located at a specified path.\n\nDynamic attributes have a defined data type and a sys\\_id. For more details on dynamic attributes, see [Dynamic schema](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/dynamic-schema.md).\n\nSee also:\n\n-   [GlideDynamicAttribute - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideDynamicAttributeAPI.md)\n-   [GlideDynamicAttributeStore - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideDynamicAttStoreAPI.md)\n-   [GlideDynamicNamespace - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideDynamicNamespaceAPI.md)\n\n<table id=\"table_ynk_tdx_1bc\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nfullPath\n\n</td><td>\n\nString\n\n</td><td>\n\nPath to use to locate the desired dynamic attribute. Format of the attribute path: `dyn_att_field->attr_name`\n\n-   `dyn_att_field`: Name of a dynamic attribute store field on the table.\n-   `attr_name`: Name of the dynamic attribute.\n\nTable: Dynamic Attribute \\[dynamic\\_attribute\\]\n\n\nSee also [Dynamic Schema](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/dynamic-schema.md).\n\n</td></tr><tr><td>\n\nvalue\n\n</td><td>\n\nObject\n\n</td><td>\n\nValue to set the specified dynamic attribute to.The passed value must be of one of the following data types:\n\n-   Boolean \\(True/False\\)\n-   Decimal\n-   Floating Point Number\n-   GlideDate\n-   GlideDateTime\n-   Integer\n-   String\n\n</td></tr></tbody>\n</table><table id=\"table_znk_tdx_1bc\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether the dynamic attribute was successfully updated.Possible values:\n\n-   true: Dynamic attribute was successfully updated.\n-   false: Error occurred. Dynamic attribute wasn't updated. Verify that the **fullPath** parameter contains a valid path to the desired attribute.\n\n</td></tr></tbody>\n</table>The following code example shows how to call this method.\n\n```\nvar gr_Inc = new GlideRecord('incident');\ngr_Inc.setDynamicAttributeValue(\"inc_dynamic_schema->color\",\"black\");\ngr_Inc.setDynamicAttributeValue(\"inc_dynamic_schema->make\",\"Honda\");\ngr_Inc.setDynamicAttributeValue(\"inc_dynamic_schema->model\",\"CRV\");\ngr_Inc.setDynamicAttributeValue(\"inc_dynamic_schema->luxury\",false);\ngr_Inc.setDynamicAttributeValue(\"inc_dynamic_schema->cost\",20000);\ngr_Inc.setDynamicAttributeValue(\"inc_dynamic_schema->avg_mpg\",28.4);\ngr_Inc.setDynamicAttributeValue(\"inc_dynamic_schema->date_purchased\", new GlideDateTime());\ngr_Inc.setDynamicAttributeValue(\"u_attributes->total_miles\", 120000.12345);\ngr_Inc.insert();\n```\n\n## GlideRecord - setDynamicAttributeValue\\(String dynamicAttributeField, String attrPath, Object value\\)\n\nSets the value of the dynamic attribute located in a specified field of the current GlideRecord and a specified attribute path.\n\nDynamic attributes have a defined data type and a sys\\_id. For more details on dynamic attributes, see [Dynamic schema](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/dynamic-schema.md).\n\nSee also:\n\n-   [GlideDynamicAttribute - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideDynamicAttributeAPI.md)\n-   [GlideDynamicAttributeStore - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideDynamicAttStoreAPI.md)\n-   [GlideDynamicNamespace - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideDynamicNamespaceAPI.md)\n\n<table id=\"table_l12_f2x_1bc\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\ndynamicAttributeField\n\n</td><td>\n\nString\n\n</td><td id=\"DynS-dynamicAttributeField-entry\">\n\nName of the field in the table that contains the dynamic attribute.\n\n</td></tr><tr><td>\n\nattributePath\n\n</td><td>\n\nString\n\n</td><td>\n\nAttribute path to use to locate the associated dynamic schema attribute.Format: `\"attr_name\"`\n\n`attr_name`: Name of the dynamic attribute.\n\nTable: In the attribute field of the Dynamic Attribute \\[dynamic\\_attribute\\] table.\n\n</td></tr><tr><td>\n\nvalue\n\n</td><td>\n\nObject\n\n</td><td>\n\nValue to set the specified dynamic attribute to.The passed value must be of one of the following data types:\n\n-   Boolean \\(True/False\\)\n-   Decimal\n-   Floating Point Number\n-   GlideDate\n-   GlideDateTime\n-   Integer\n-   String\n\n</td></tr></tbody>\n</table><table id=\"table_m12_f2x_1bc\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether the dynamic attribute was successfully updated.Possible values:\n\n-   true: Dynamic attribute was successfully updated.\n-   false: Error occurred. Dynamic attribute wasn't updated. Verify that the **dynamicAttributeField** and **attrPath** parameters contain valid data.\n\n</td></tr></tbody>\n</table>The following code example shows how to call this method.\n\n```\n// Update the value of the attribute 'attribute_store->time_of_purchase' incident INC0009009 to a timestamp (in UTC)\nvar gr1 = new GlideRecord('incident');\ngr1.get('number', 'INC0009009');\ngr1.setDynamicAttributeValue('attribute_store', 'time_of_purchase', '2020-05-13 13:52:44');\ngr1.update();\n\n// Then retrieve the value of the attribute on the same record\nvar gr2 = new GlideRecord('incident');\ngr2.get('number', 'INC0009009');\ngs.info(\"Time of Purchase Value        (UTC): \" + gr2.getDynamicAttributeValue('attribute_store', 'time_of_purchase'));\ngs.info(\"Time of Purchase DisplayValue (PST): \" + gr2.getDynamicAttributeDisplayValue('attribute_store', 'time_of_purchase'));\n```\n\nOutput:\n\n```\n*** Script: Time of Purchase Value        (UTC): 2020-05-13 13:52:44\n*** Script: Time of Purchase DisplayValue (PST): 2020-05-13 06:52:44\n```\n\n## GlideRecord - setDynamicAttributeDisplayValue\\(String fullPath, Object value\\)\n\nSets the display value of the dynamic attribute located at a specified path.\n\nDynamic attributes have a defined data type and a sys\\_id. For more details on dynamic attributes, see [Dynamic schema](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/dynamic-schema.md).\n\nSee also:\n\n-   [GlideDynamicAttribute - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideDynamicAttributeAPI.md)\n-   [GlideDynamicAttributeStore - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideDynamicAttStoreAPI.md)\n-   [GlideDynamicNamespace - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideDynamicNamespaceAPI.md)\n\n<table id=\"table_g4h_s2x_1bc\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nfullPath\n\n</td><td>\n\nString\n\n</td><td>\n\nPath to use to locate the dynamic attribute whose display value you want to update. Format of the attribute path: `dyn_att_field->attr_name`\n\n-   `dyn_att_field`: Name of a dynamic attribute store field on the table.\n-   `attr_name`: Name of the dynamic attribute.\n\nTable: Dynamic Attribute \\[dynamic\\_attribute\\]\n\n\nSee also [Dynamic Schema](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/dynamic-schema.md).\n\n</td></tr><tr><td>\n\nvalue\n\n</td><td>\n\nObject\n\n</td><td>\n\nDisplay value to set the specified dynamic attribute to.The passed value must be of one of the following data types:\n\n-   Boolean \\(True/False\\)\n-   Decimal\n-   Floating Point Number\n-   GlideDate\n-   GlideDateTime\n-   Integer\n-   String\n\n</td></tr></tbody>\n</table><table id=\"table_h4h_s2x_1bc\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether the display value of the dynamic attribute was successfully updated.Possible values:\n\n-   true: Display value of the dynamic attribute was successfully updated.\n-   false: Error occurred. Display value of the dynamic attribute wasn't updated. Verify that the **fullPath** parameter contains a valid path to the desired attribute.\n\n</td></tr></tbody>\n</table>The following code example shows how to call this method.\n\n```\nvar grProdTab = new GlideRecord('products_table');\ngrProdTab.query();\ngrProdTab.next();\nvar val = grProdTab.setDynamicAttributeDisplayValue('product_details->date_purchased', '2023-03-31 08:54:26');\n```\n\n## GlideRecord - setDynamicAttributeDisplayValue\\(String dynamicAttributeField, String attrPath, Object value\\)\n\nSets the display value of the dynamic attribute located in a specified field of the current GlideRecord and a specified attribute path.\n\nDynamic attributes have a defined data type and a sys\\_id. For more details on dynamic attributes, see [Dynamic schema](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/dynamic-schema.md).\n\nSee also:\n\n-   [GlideDynamicAttribute - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideDynamicAttributeAPI.md)\n-   [GlideDynamicAttributeStore - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideDynamicAttStoreAPI.md)\n-   [GlideDynamicNamespace - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideDynamicNamespaceAPI.md)\n\n<table id=\"table_l1k_1fx_1bc\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\ndynamicAttributeField\n\n</td><td>\n\nString\n\n</td><td id=\"DynS-dynamicAttributeField-entry\">\n\nName of the field in the table that contains the dynamic attribute.\n\n</td></tr><tr><td>\n\nattrPath\n\n</td><td>\n\nString\n\n</td><td>\n\nAttribute path to use to locate the associated dynamic schema attribute.Format: `\"attr_name\"`\n\n`attr_name`: Name of the dynamic attribute.\n\nTable: In the attribute field of the Dynamic Attribute \\[dynamic\\_attribute\\] table.\n\n</td></tr><tr><td>\n\nvalue\n\n</td><td>\n\nObject\n\n</td><td>\n\nDisplay value to set the specified dynamic attribute to.The passed value must be of one of the following data types:\n\n-   Boolean \\(True/False\\)\n-   Decimal\n-   Floating Point Number\n-   GlideDate\n-   GlideDateTime\n-   Integer\n-   String\n\n</td></tr></tbody>\n</table><table id=\"table_m1k_1fx_1bc\" class=\"returns\"><thead><tr><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether the display value of the dynamic attribute was successfully updated.Possible values:\n\n-   true: Display value of the dynamic attribute was successfully updated.\n-   false: Error occurred. Display value of the dynamic attribute wasn't updated. Verify that the **dynamicAttributeField** and **attrPath** parameters contain valid data.\n\n</td></tr></tbody>\n</table>The following code example shows how to call this method.\n\n```\nvar grProdTab = new GlideRecord('products_table');\ngrProdTab.query();\ngrProdTab.next();\nvar val = grProdTab.setDynamicAttributeDisplayValue('product_details', 'date_purchased', '2023-03-31 08:54:26');\n```\n\n## GlideRecord - setDynamicAttributeValues\\(String dynamicAttributeField, GlideDynamicAttributeStore values\\)\n\nSets one or more dynamic attribute values with values specified in the passed GlideDynamicAttributeStore object.\n\nThis method only updates the attributes and values passed in as arguments. Attributes and values on the GlideRecord that aren't specified are unaffected by this call. Any invalid attributes or values are ignored. Check the log messages for possible error information.\n\nDynamic attributes have a defined data type and a sys\\_id. For more details on dynamic attributes, see [Dynamic schema](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/dynamic-schema.md).\n\nSee also:\n\n-   [GlideDynamicAttribute - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideDynamicAttributeAPI.md)\n-   [GlideDynamicAttributeStore - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideDynamicAttStoreAPI.md)\n-   [GlideDynamicNamespace - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideDynamicNamespaceAPI.md)\n\n<table id=\"table_r5l_4fx_1bc\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\ndynamicAttributeField\n\n</td><td>\n\nString\n\n</td><td>\n\nName of the field in the current table that contains the [dynamic schema](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/dynamic-schema.md).\n\n</td></tr><tr><td>\n\nvalues\n\n</td><td>\n\n[GlideDynamicAttributeStore](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/GlideDynamicAttStoreAPI.md)\n\n</td><td>\n\nGlideDynamicAttributeStore object that contains the dynamic attributes to update.The values populated in the object must be of the following data types:\n\n-   Boolean \\(True/False\\)\n-   Decimal\n-   Floating Point Number\n-   GlideDate\n-   GlideDateTime\n-   Integer\n-   String\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|None| |\n\nThe following code example shows how to call this method.\n\n```\nvar das = new GlideDynamicAttributeStore();\ndas.setDynamicAttributeValue('attribute1', 'Apple');\ndas.setDynamicAttributeValue('attribute2', 1234);\n\nvar gr_Inc = new GlideRecord('incident');\ngr_Inc.query();\ngr_Inc.next();\ngr_Inc.setDynamicAttributeValues(das);\n```\n\n## GlideRecord - setForceUpdate\\(Boolean force\\)\n\nUpdates the record even if fields have not changed.\n\n|Name|Type|Description|\n|----|----|-----------|\n|force|Boolean|True to update even if fields have not changed, otherwise false.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\nThis example shows how to force a record in the itfm\\_cost\\_model table to update even without changes.\n\n```\nfunction() {\n  gs.log(\"Update Script: Upgrade_cost_model_data.js started\");\n  var now_GR = new GlideRecord(\"itfm_cost_model\");\n  now_GR.initialize();\n  now_GR.addNullQuery(\"source_table\");\n  now_GR.query();\n  while (now_GR.next()) {\n    now_GR.setForceUpdate(true);\n    var sourceTable = getSourceTable(now_GR.getValue('clone_from'));\n    if(sourceTable){\n      now_GR.setValue(\"source_table\", sourceTable);\n      now_GR.setWorkflow(false);\n      now_GR.update();\n    }\n  }\n}\n```\n\n## GlideRecord - setLimit\\(Number limit\\)\n\nSets the maximum number of records to return in the GlideRecord from a query.\n\n-   **Using setLimit\\(\\) with chooseWindow\\(\\)**\n\n    The setLimit\\(\\) method implicitly calls the chooseWindow\\(\\) method and might cause unexpected results when used with chooseWindow\\(\\) in a query.\n\n    -   If the chooseWindow\\(\\) method is called first, its record window is overwritten by the setLimit\\(\\) method.\n\n        Using the following lines in a query returns 100 records starting at row 1:\n\n        ```\n        grIncident.chooseWindow(20,30);\n        grIncident.setLimit(100);\n        ```\n\n    -   If the setLimit\\(\\) method is called first, the window set by chooseWindow\\(\\) is used and the limit is overwritten.\n\n        Using the following lines in a query returns 10 records starting at row 21:\n\n        ```\n        grIncident.setLimit(5);\n        grIncident.chooseWindow(20,30);\n        ```\n\n        **Note:** Running query\\(\\) with the chooseWindow\\(\\) method triggers a `COUNT(*)` query, which can result in slow performance on tables with a large number of records. You can use setLimit\\(\\) before chooseWindow\\(\\) to skip running the `COUNT(*)` query, but the same performance benefit is achievable using setNoCount\\(\\).\n\n\nSee also:\n\n-   [chooseWindow\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md)\n-   [query\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md)\n-   [setNoCount\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md)\n\n|Name|Type|Description|\n|----|----|-----------|\n|limit|Number|Limit for records to fetch.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\nThis example sets the number of records returned in the query to a maximum of ten.\n\n```\nvar now_GR = new GlideRecord('incident');\nnow_GR.orderByDesc('sys_created_on');\nnow_GR.setLimit(10);\nnow_GR.query();\n```\n\n### Scoped equivalent\n\nTo use the setLimit\\(\\) method in a scoped application, use the corresponding scoped method: [setLimit\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - setLocation\\(Number rowNumber\\)\n\nSets the current row location to the specified value.\n\n|Name|Type|Description|\n|----|----|-----------|\n|rowNumber|Number|Row number to set as the current row.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\nThis example shows how to set the record position in the Incident table\n\n```\nverifySetLocation : function() {\n  var now_GR = new GlideRecord(\"incident\");\n  now_GR.query();\n  var recordIDs = new Array();\n  while(now_GR.next()) {\n  recordIDs.push(now_GR.getValue(\"sys_id\"));\n  }\n  for (var ix = recordIDs.length - 1; ix >= 0; ix--) {\n    now_GR.setLocation(ix);\n    Assert.assertEquals(recordIDs[ix], now_GR.getValue(\"sys_id\"),\n      \"The entry retrieved for the index \" + ix + \" is not valid\");\n  }\n}\n```\n\n## GlideRecord - setNewGuid\\(\\)\n\nGenerates a new GUID and sets it as the unique ID \\(sys\\_id\\) for the current record.\n\nThis function applies only to new records. You cannot change the GUID for an existing record.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|String|Sys\\_id of the current record.|\n\nThis example creates a new task record and stores the ID in the task\\_rel\\_task table.\n\n```\nvar task = new GlideRecord ('task');\nvar tsk_id = task.setNewGuid();\n \ntask.description = \"Request: \" + current.request.number;\ntask.description = task.description + \"\\n\" + \"Requested by: \" + current.request.u_requested_by.name;\ntask.description = task.description + \"\\n\" + \"Requested for: \" + current.request.u_requested_for.name;\ntask.description = task.description + \"\\n\" + \"Item: \" + current.cat_item.name;\n \nvar now_GR = new GlideRecord ('task_rel_task');\n//link the incident to the request\nnow_GR.parent = current.request;\nnow_GR.child = tsk_id;\nnow_GR.insert();\n```\n\n## GlideRecord - setNewGuidValue \\(String guid\\)\n\nGenerates a new GUID and sets it as the unique ID for the current record, when inserting a new record.\n\n|Name|Type|Description|\n|----|----|-----------|\n|guid|String|Value for the new GUID.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\nThis example generates a new GUID and sets it as the unique ID for the newly created cmdb\\_software\\_instance record.\n\n```\nvar gobj = new GlideRecord('sys_db_object');\ngobj.addQuery('name','cmdb_software_instance');\ngobj.query();\nif (!gobj.next()) {\n  var si = new GlideRecord('cmdb_software_instance');\n  si.query();\n  var count = 0;\n  while (si.next()) {\n  if (!si.isValidField('sys_class_name')) {\n    var ci = new GlideRecord('cmdb_ci');\n    ci.name = si.name;\n    ci.setNewGuidValue(si.sys_id);\n    ci.sys_class_name = 'cmdb_software_instance';\n    ci.insert();\n    count++;\n  }\n}\n```\n\n### Scoped equivalent\n\nTo use the setNewGuidValue\\(\\) method in a scoped application, use the corresponding scoped method: [setNewGuidValue\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - setNoCount\\(\\)\n\nStops a GlideRecord query from running a `COUNT(*)` query.\n\nRunning query\\(\\) with some methods trigger a `COUNT(*)` query, such as the chooseWindow\\(\\) and getRowCount\\(\\) methods. The `COUNT(*)` query might cause slow performance on tables with a million or more records. For more information, see the [Performance Improvement - Remove Pagination Count \\[KB0817996\\]](https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0817996) article in the Now Support Knowledge Base.\n\n**Note:** The setLimit\\(\\) method also stops a `COUNT(*)`. Using setNoCount\\(\\) is unnecessary if the setLimit\\(\\) method is included in the query.\n\nSee also:\n\n-   [chooseWindow\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md)\n-   [query\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordAPI.md)\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|void| |\n\nThe following code example shows how to use setNoCount\\(\\) to skip the `COUNT(*)` query on a windowed query set using the chooseWindow\\(\\) method.\n\n```\nvar  grIncident = new GlideRecord('incident');\n\ngrIncident.chooseWindow(6915, 6920, true);\ngrIncident.setNoCount();\ngrIncident.query();\n\nwhile (grIncident.next()) { // Iterate through the returned records\n    gs.info('Incident Number: ' + grIncident.number + ', Short Description: ' + grIncident.short_description);\n};\n```\n\nOutput:\n\n```\nIncident Number: INC0006811, Short Description: Request an account to be created for Fidelity 401(k) Plans\nIncident Number: INC0006918, Short Description: Please grant me additional roles in Oracle Fin Collections\nIncident Number: INC0006812, Short Description: Taxware Value-added Tax crashes when I try to launch it\nIncident Number: INC0006919, Short Description: Unable to Access SuccessFactors Learning\nIncident Number: INC0010004, Short Description: Incident for assessment not generating\n```\n\n### Scoped equivalent\n\nTo use the setNoCount\\(\\) method in a scoped application, use the corresponding scoped method: [setNoCount\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - setQueryReferences\\(Boolean queryReferences\\)\n\nEnables or disables using the reference field's display name when querying a reference field.\n\n<table id=\"table_zyr_ljw_dt\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nqueryReferences\n\n</td><td>\n\nBoolean\n\n</td><td>\n\nFlag indicating what time of data to generate.Valid values:\n\n-   true: Generate a string of display names.\n-   false: Generate a string of sys\\_ids.\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|void| |\n\n```\nvar grByName = new GlideRecord(this.TEST_TABLE);\ngrByName.addQuery(\"caller_id\", userDisplayName);\ngrByName.setQueryReferences(true);\ngrByName.query();\nif (grByName.hasNext()) {\n  while(grByName.next()) {\n    gs.print(\"Incident caller_id=\" + grByName.caller_id);\n  }\n} else {\n  gs.print(\"NO RESULTS\");\n}\n```\n\n## GlideRecord - setUseEngines\\(Boolean e\\)\n\nDisables or enables the running of any engines \\(approval rules / assignment rules\\).\n\n**Warning:** Disabling the running of engines can have a significant impact on your ServiceNow® instance and how it operates. Ensure that you thoroughly test this change before deploying it to production.\n\n<table id=\"table_gdy_vjw_dt\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\ne\n\n</td><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether to enable or disable the running of any engines.Valid values:\n\n-   true: Enable engines\n-   false: Disable engines\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|void| |\n\nThis example shows how to disable engines and business rules before executing a query.\n\n```\nfunction auditOAuthInboundRequestsUsage(){\n  var now_GR = new GlideRecord(\"oauth_credential\");\n  var oauthClient = now_GR.addJoinQuery(\"oauth_entity\", \"peer\", \"sys_id\");\n  now_GR.addQuery(\"type\", \"access_token\");\n  now_GR.addQuery(\"expires\", \">\", nowDateTime());\n  now_GR.addNullQuery(\"oauth_requestor_profile\");\n  oauthClient.addCondition(\"active\", \"true\");\n  oauthClient.addCondition(\"type\", \"client\");\n  now_GR.setUseEngines(false);\n  now_GR.setWorkflow(false);\n  now_GR.query();\n  return now_GR.hasNext();\n}\n```\n\n## GlideRecord - setValue\\(String name, Object value\\)\n\nSets the specified field, or an attribute in a dynamic attribute store, to a specified value.\n\nNormally a script would do a direct assignment, for example `now_GR.category = value`. However, if in a script the element name is a variable, then you can use `now_GR.setValue(elementName, value)`. When setting a value, ensure that the data type of the field matches the data type of the value you enter. For information about the differences between using setValue\\(\\) and direct assignment, see [Explanation of Assignment Behavior for Reference GlideList Fields \\[KB2557324\\]](https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB2557324) in the Now Support Knowledge Base.\n\nIf the value parameter is null, the record isn't updated, and an error isn't thrown.\n\n**Note:** This method can't be used on journal fields. Use [GlideElement.setJournalEntry\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideElementAPI.md) instead.\n\n**Note:** If the Field Encryption Enterprise plugin is enabled and the instance has access to the key, this method can insert encrypted data into encrypted fields. If the instance does not have access to the key, this method returns an error. For more information, see [Platform Encryption](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-security/encryption-landing.md).\n\n-   **Not for authentication with password2 fields**\n\n    The setValue\\(\\) method passes password2 data as clear text, which results in an error about expecting encrypted data. Additionally, using the setValue\\(\\) method for password2 fields exposes data that should be encrypted.\n\n    For password2 authentication, use the setDisplayValue\\(\\) method instead.\n\n    See also:\n\n    -   [Deprecate GlideEncrypter usage of 3DES for password2 fields](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-security/password2-3des-deprecation.md)\n    -   [Alternatives to GlideEncrypter usage in knowledge base article KB1320986](https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB1320986)\n    -   [Password2 encryption with the Key Management Framework \\(KMF\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-security/password-2way-encrypted-fields.md)\n\n<table id=\"table_yps_2kw_dt\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nname\n\n</td><td>\n\nString\n\n</td><td>\n\nName of the field to be set.To set attribute values in dynamic schema, use the path to an attribute within a dynamic attribute store.\n\nFormat of the attribute path: `dyn_att_field->attr_name`\n\n-   `dyn_att_field`: Name of a dynamic attribute store field on the table.\n-   `attr_name`: Name of the dynamic attribute.\n\nTable: Dynamic Attribute \\[dynamic\\_attribute\\]\n\n\nSee also [Dynamic Schema](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/dynamic-schema.md).\n\n</td></tr><tr><td>\n\nvalue\n\n</td><td>\n\nObject\n\n</td><td>\n\nValue to set in the specified field.**Note:** For a dynamic attribute, only the following data types are supported:\n\n-   Boolean \\(True/False\\)\n-   Decimal\n-   Floating Point Number\n-   GlideDate\n-   GlideDateTime\n-   Integer\n-   String\n\nTo specify a dynamic category field in dynamic schema, use a reference key with the namespace and category field name instead of a sys\\_id. Provide the category column as the name parameter, e.g., `grExample.setValue('cat_column_name', 'namespace_name/cat_name')`. For more information, see [Create a dynamic namespace](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/create-dynamic-namespace.md).\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|None| |\n\nThis example shows how to set the value of the state field in the planned\\_task table.\n\n```\nfunction() {\n  var topTask = new GlideRecord('planned_task');\n  topTask.setValue('state', -5);\n  var childTask = new GlideRecord('planned_task');\n  childTask.setValue('state', -5);\n  var s = new PlannedTaskStateManagement(childTask, topTask);\n  var state = s.manageStateChange(false);\n  Assert.assertEquals(\"-5\", state);\n}\n```\n\nThis example shows how to use this method with dynamic schema. The first usage sets the value of a dynamic category using a reference key to set the value. The second uses an attribute path to set the value of a dynamic attribute called `total_miles`.\n\n```\nvar used_car = new GlideRecord('u_product');\n\n// Using setValue() to set the dynamic category column to Car\n// u_product/u_attributes is the namespace and u_car is the category\nused_car.setValue('u_attributes_category', 'u_product/u_attributes/u_car');\n\n// Using setDynamicAttributeValue() to set the dynamic attribute value\nused_car.setDynamicAttributeValue(\"u_attributes->color\",\"green\");\nused_car.setDynamicAttributeValue(\"u_attributes->make\",\"Toyota\");\nused_car.setDynamicAttributeValue(\"u_attributes->model\",\"Rav4\");\nused_car.setDynamicAttributeValue(\"u_attributes->luxury\",false);\nused_car.setDynamicAttributeValue(\"u_attributes->cost\",12500);\nused_car.setDynamicAttributeValue(\"u_attributes->avg_mpg\",24.8);\nused_car.setDynamicAttributeValue(\"u_attributes->date_purchased\", new GlideDateTime());\n\n// Using setValue() to set the dynamic attribute value\nused_car.setValue(\"u_attributes->total_miles\", 120000.12345);\n\nused_car.insert();\n```\n\n### Scoped equivalent\n\nTo use the setValue\\(\\) method in a scoped application, use the corresponding scoped method: [setValue\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - setWorkflow\\(Boolean enable\\)\n\nEnables or disables running business rules that might normally be triggered by subsequent actions.\n\n**Note:** The setWorkflow\\(\\) method is ignored when subsequently using either the deleteProblem\\(\\) or deleteMultiple\\(\\) methods to cascade delete.\n\n**Warning:** Disabling the running of business rules can have a significant impact on your ServiceNow® instance and how it operates. Ensure that you thoroughly test this change before deploying it to production.\n\n<table id=\"table_vy2_525_jq\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nenable\n\n</td><td>\n\nBoolean\n\n</td><td>\n\nFlag that indicates whether to enable or disable the running of business rules, script engines, and audit.Valid values:\n\n-   true: Enables running business rules, script engines, or audits.\n-   false: Disables running business rules, script engines, or audits.\n\nDefault: true\n\n</td></tr></tbody>\n</table>|Type|Description|\n|----|-----------|\n|None| |\n\n```\ndoit('name1','name2'); \n \nfunction doit(username1,username2) { \n \n  var usr1 = new GlideRecord('sys_user');\n  var usr2 = new GlideRecord('sys_user');\n  var num = 0;\n \n  if (usr1.get('user_name',username1) && usr2.get('user_name',username2)) {\n    var ref;\n    var dict = new GlideRecord('sys_dictionary');\n    dict.addQuery('reference','sys_user');\n    dict.addQuery('internal_type','reference');\n    dict.query();\n    while (dict.next()) {\n      num = 0;\n      ref = new GlideRecord(dict.name.toString());\n      ref.addQuery(dict.element,usr1.sys_id);\n      ref.query();\n      while (ref.next()) {\n        ref.setValue(dict.element.toString(),usr2.sys_id); \n        ref.setWorkflow(false);\n        ref.update();\n        num++;\n      }\n      if (num > 0) {\n        gs.print(dict.element + ' changed from ' + usr1.user_name + \n          ' to ' + usr2.user_name + ' in ' + num + ' ' + dict.name + ' records');\n      }\n    }\n  }\n}\n```\n\n### Scoped equivalent\n\nTo use the setWorkflow\\(\\) method in a scoped application, use the corresponding scoped method: [setWorkflow\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - update\\(Object reason\\)\n\nUpdates the GlideRecord with any changes that have been made. If the record does not exist, it is inserted.\n\n|Name|Type|Description|\n|----|----|-----------|\n|reason|Object|Optional. Reason for the update. The reason appears in the audit record.|\n\n|Type|Description|\n|----|-----------|\n|String|The sys\\_id of the new or update record. Returns null if the update fails.|\n\nThis example updates a record in the task\\_ci table.\n\n```\nvar now_GR = new GlideRecord('task_ci');\nnow_GR.addQuery();\nnow_GR.query();\nvar count = now_GR.getRowCount();\nif (count > 0) {\n   var allocation = parseInt(10000 / count) / 100;\n   while (now_GR.next()) {\n      now_GR.u_allocation = allocation;\n      now_GR.update();\n   }\n}\n```\n\n### Scoped equivalent\n\nTo use the update\\(\\) method in a scoped application, use the corresponding scoped method: [update\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - updateMultiple\\(\\)\n\nUpdates each GlideRecord in a stated query with a specified set of changes.\n\nFor information on adding journal entries, refer to the [setJournalEntry\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideElementAPI.md) method.\n\nThe **glide.db.forced.chunk.threshold** system property sets the threshold above which forces chunk record deletions and updates. Chunking helps to prevent non-primary key deletions on huge tables from causing replication problems. For more information, see [Available system properties](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/r_AvailableSystemProperties.md).\n\n**Note:** To ensure expected results, use the setValue\\(\\) method instead of direct assignments. That is, use `gr_Now.setValue('<field_name>', '4'));` instead of `gr_Now.<field_name> = 4`.\n\n**Note:** Do not use this method with the chooseWindow\\(\\) or setLimit\\(\\) methods when working with large tables.\n\nThis method sets new values and does not clear existing values. To clear an existing value, use the setValue\\(\\) method and set the field to 'NULL'. For more information, see [Setting a GlideRecord variable to 'NULL'](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/scripts/r_SettingAGlideRecordVariableToNull.md).\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|None| |\n\nThis example shows how to update the state of all active incidents to 4 - \"Awaiting User Info\".\n\n```\nvar now_GR = new GlideRecord('incident');\nnow_GR.addQuery('active', true);\nnow_GR.setValue('state',  4);\nnow_GR.updateMultiple();\n```\n\nThis example shows how to clear existing values of the description field for priority 1 incidents.\n\n```\nvar test = new GlideRecord('incident');\ntest.addEncodedQuery('priority=1');\ntest.query();\n \ntest.setValue('description','NULL');\ntest.updateMultiple();\n```\n\n### Scoped equivalent\n\nTo use the updateMultiple\\(\\) method in a scoped application, use the corresponding scoped method: [updateMultiple\\(\\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/c_GlideRecordScopedAPI.md).\n\n## GlideRecord - updateWithReferences\\(Object reason\\)\n\nUpdates a record and also inserts or updates any related records with the information provided.\n\n|Name|Type|Description|\n|----|----|-----------|\n|reason|Object|Reason for the updates. The reason is displayed in the audit record.|\n\n|Type|Description|\n|----|-----------|\n|String|The sys\\_id for the record being updated.|\n\nIf processing an incident where the Caller ID is set to reference sys\\_user record 'John Doe,' then the following code would update John Doe's user record. If processing an incident where there's no caller ID specified, then the following code creates a new sys\\_user record with the provided information \\(first\\_name, last\\_name\\) and sets the caller ID value to the newly created sys\\_user record.\n\n```\nvar inc = new GlideRecord('incident');\ninc.get(inc_sys_id);  // Looking up an existing incident record where 'inc_sys_id' represents the sys_id of a incident record\ninc.caller_id.first_name = 'John';\ninc.caller_id.last_name = 'Doe';\ninc.updateWithReferences();\n}\n```\n\n"}}