How to reset GlideRecord object
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2016 03:45 AM
Hello,
I have a code like this
var gr = new GlideRecord('myTable');
for(int i=0;i<5;i++){
gr.addQuery('column', i)
gr.query();
gr.getrowcount();
}
Problem is, for i=0 it works but for next iterator it appends the addQuery condition to previous one. Example
i=0 condition is column=0
i=1 condition is column=0^column=1
.
.
i=4 condition is column=0^column=1^column=2^column=3^column=4
My question is, how I can rest the gr after each loop, so that only one addQuery is added not the previous one?
Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2020 06:08 AM
You are correct. Server side code is run in Rhino. The ServiceNow platform code is in Java. We expose APIs like GlideRecord, GlideSystem, etc. to the Javascript layer so you can gain database and performance from the server. Running everything on the client would be a technical headache on a platform of this scale, in my opinion. I'm really glad we have server side code.
In general, I only worry about performance when I hear of use cases with LOTS of records or transactions. (E.g. millions) Often times, a good query to filter things down cures much of that.