Resolve unexpected script results caused by using "gr" as a GlideRecord variable nameIssue <!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } span { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } h2 { font-size: 24pt; font-family: Lato; color: var(--now-color--text-primary, black); } h3 { font-size: 18pt; font-family: Lato; color: var(--now-color--text-primary, black); } h4 { font-size: 14pt; font-family: Lato; color: var(--now-color--text-primary, black); } a { font-size: 12pt; font-family: Lato; color: var(--now-color--link-primary, #00718F); } a:hover { font-size: 12pt; color: var(--now-color--link-primary, #024F69); } a:target { font-size: 12pt; color: var(--now-color--link-primary, #032D42); } a:visited { font-size: 12pt; color: var(--now-color--link-primary, #00718f); } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } Resolve unexpected script behavior caused by using "gr" as a GlideRecord variable name. The variable "gr" is globally declared in multiple areas of core platform functionality. When scripts use this variable name, conflicts can occur with existing platform code that uses the same variable. A common symptom is that a background script intended to update multiple records updates only one. The following script illustrates this pattern: var gr = new GlideRecord("cmdb_ci_ip_address"); //Need to set the encoded query below var temp = ""; gr.addEncodedQuery(temp); gr.setLimit(100); gr.query(); gs.print(gr.getRowCount()); while (gr.next()) { gr.install_status = '7'; gr.update(); } If this script updates only one record instead of all matching records, the cause is likely a variable name conflict with the global "gr" variable. Release<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } span { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } h2 { font-size: 24pt; font-family: Lato; color: var(--now-color--text-primary, black); } h3 { font-size: 18pt; font-family: Lato; color: var(--now-color--text-primary, black); } h4 { font-size: 14pt; font-family: Lato; color: var(--now-color--text-primary, black); } a { font-size: 12pt; font-family: Lato; color: var(--now-color--link-primary, #00718F); } a:hover { font-size: 12pt; color: var(--now-color--link-primary, #024F69); } a:target { font-size: 12pt; color: var(--now-color--link-primary, #032D42); } a:visited { font-size: 12pt; color: var(--now-color--link-primary, #00718f); } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } All supported releases Cause<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } span { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } h2 { font-size: 24pt; font-family: Lato; color: var(--now-color--text-primary, black); } h3 { font-size: 18pt; font-family: Lato; color: var(--now-color--text-primary, black); } h4 { font-size: 14pt; font-family: Lato; color: var(--now-color--text-primary, black); } a { font-size: 12pt; font-family: Lato; color: var(--now-color--link-primary, #00718F); } a:hover { font-size: 12pt; color: var(--now-color--link-primary, #024F69); } a:target { font-size: 12pt; color: var(--now-color--link-primary, #032D42); } a:visited { font-size: 12pt; color: var(--now-color--link-primary, #00718f); } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } The variable "gr" is globally declared in multiple areas of core platform functionality. When a script also declares "gr" as a local variable, different execution threads can both use and alter the same "gr" variable simultaneously. One thread can change the object that "gr" references, causing unexpected behavior in another thread. This issue is not limited to "gr" — it can occur with any variable name that conflicts with a globally declared platform variable. However, because "gr" is so commonly used for GlideRecord declarations, it is the most frequently affected variable. Resolution<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } span { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } h2 { font-size: 24pt; font-family: Lato; color: var(--now-color--text-primary, black); } h3 { font-size: 18pt; font-family: Lato; color: var(--now-color--text-primary, black); } h4 { font-size: 14pt; font-family: Lato; color: var(--now-color--text-primary, black); } a { font-size: 12pt; font-family: Lato; color: var(--now-color--link-primary, #00718F); } a:hover { font-size: 12pt; color: var(--now-color--link-primary, #024F69); } a:target { font-size: 12pt; color: var(--now-color--link-primary, #032D42); } a:visited { font-size: 12pt; color: var(--now-color--link-primary, #00718f); } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } There are three options for resolving this issue. Any of the following approaches prevents the variable name conflict. Option A: Wrap the script in a named function Declare the GlideRecord variable inside a named function. Variables declared inside a function are scoped to that function and do not conflict with global variables. UpdateIPAddress(); function UpdateIPAddress() { var gr = new GlideRecord("cmdb_ci_ip_address"); //Need to set the encoded query below var temp = ""; gr.addEncodedQuery(temp); gr.setLimit(100); gr.query(); gs.print(gr.getRowCount()); while (gr.next()) { gr.install_status = '7'; gr.update(); } } Option B: Wrap the script in a self-invoking function Wrap the script in an immediately invoked function expression (IIFE). This scopes all variables to the function and prevents global variable conflicts. (function() { var gr = new GlideRecord("cmdb_ci_ip_address"); //Need to set the encoded query below var temp = ""; gr.addEncodedQuery(temp); gr.setLimit(100); gr.query(); gs.print(gr.getRowCount()); while (gr.next()) { gr.install_status = '7'; gr.update(); } })(); Option C: Use a unique variable name Rename the GlideRecord variable to something other than "gr". Using a unique, descriptive name makes a conflict significantly less likely. In the following example, the variable is renamed to "ipa" (for ip_address): var ipa = new GlideRecord("cmdb_ci_ip_address"); //Need to set the encoded query below var temp = ""; ipa.addEncodedQuery(temp); ipa.setLimit(100); ipa.query(); gs.print(ipa.getRowCount()); while (ipa.next()) { ipa.install_status = '7'; ipa.update(); } Note: If the script logic is correct and the issue persists after applying one of the options above, submit a case through Now Support for further investigation.