{"action":"closed","issue":{"url":"https://api.github.com/repos/thewhitespace/Xplore/issues/11","repository_url":"https://api.github.com/repos/thewhitespace/Xplore","labels_url":"https://api.github.com/repos/thewhitespace/Xplore/issues/11/labels{/name}","comments_url":"https://api.github.com/repos/thewhitespace/Xplore/issues/11/comments","events_url":"https://api.github.com/repos/thewhitespace/Xplore/issues/11/events","html_url":"https://github.com/thewhitespace/Xplore/issues/11","id":278265069,"number":11,"title":"GlideRecord Not looping","user":{"login":"jbgriffith","id":1854971,"avatar_url":"https://avatars1.githubusercontent.com/u/1854971?v=4","gravatar_id":"","url":"https://api.github.com/users/jbgriffith","html_url":"https://github.com/jbgriffith","followers_url":"https://api.github.com/users/jbgriffith/followers","following_url":"https://api.github.com/users/jbgriffith/following{/other_user}","gists_url":"https://api.github.com/users/jbgriffith/gists{/gist_id}","starred_url":"https://api.github.com/users/jbgriffith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbgriffith/subscriptions","organizations_url":"https://api.github.com/users/jbgriffith/orgs","repos_url":"https://api.github.com/users/jbgriffith/repos","events_url":"https://api.github.com/users/jbgriffith/events{/privacy}","received_events_url":"https://api.github.com/users/jbgriffith/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2017-11-30T20:49:45Z","updated_at":"2018-02-05T00:17:15Z","closed_at":"2018-02-05T00:17:15Z","author_association":"NONE","body":"I'm running Jakarta Patch5. \r\nI ran a simple query to delete some records, and noticed that it was too fast for what I wanted.\r\n\r\n\r\n```javascript\r\nvar gr = new GlideRecord('sys_user_group');\r\ngr.addEncodedQuery(\"sys_created_onON2017-11-22@javascript:gs.dateGenerate('2017-11-22','start')@javascript:gs.dateGenerate('2017-11-22','end')\");\r\n\r\ngr.query();\r\nwhile (gr.next()) {\r\n    gs.log(gr.u_friendly_name, 'Deleting Groups');\r\n    gr.deleteRecord();\r\n}\r\n```\r\n\r\nThe result was: \r\nAs you can see it took ~4 seconds, I have about 8000 of these groups that were created on the specified date. So I added the log to see how many records it was deleting, and it was one at a time... Since it's showing \"true\" as the Value, I'm assuming it's showing the next value returned from gr.next() (the condition in the while loop)\r\n \r\n\r\n![Looping issue](https://ibin.co/3j72j0Jgghng.jpg)\r\n\r\n\r\nI then decided to do another sanity check before I send you an issue.\r\n\r\n\r\n```javascript\r\nvar count = 0;\r\nvar gr = new GlideRecord('sys_user_group');\r\ngr.addEncodedQuery(\"sys_created_onON2017-11-22@javascript:gs.dateGenerate('2017-11-22','start')@javascript:gs.dateGenerate('2017-11-22','end')\");\r\n\r\ngr.query();\r\ngs.addInfoMessage('# records: ' + gr.getRowCount());\r\n\r\nwhile (gr.next()) {\r\n    gs.log(gr.u_friendly_name, 'Deleting Groups');\r\n    var wasDeleted = gr.deleteRecord();\r\n    if (wasDeleted) { \r\n        count++;\r\n    }\r\n}\r\ngs.addInfoMessage('# Deleted: ' + count);\r\n```\r\n\r\n\r\n![Looping issue 2](https://ibin.co/3j77ANeFGTZB.jpg)"}}
{"actor":{"display_login":"jneale"}}