The CreatorCon Call for Content is officially open! Get started here.

How to close or terminate a gliderecord

Stewe Lundin
Mega Guru

I wondering if there is some way to clean up the gliderecords as i go forward in my scripts.
I'm currently working on some UI pages, and to get te data I need I have to ask e few (some times a lot) different query's towards different tables in the database. SOme times the are up in the tens of thousands of rows.

Not huge amounts of data but anyhow.
Java is not my strongest of fields, I'm more of a VB scripter from the beginning. And I'm use to clean up and close down FSO and or dataSetRecords after I'v collected my data.

I'v checked the Wiki for GlideRecord but not found a close function. So how to close my connection and free up the memory. This is not an issue now, but perhaps in the future when the amounts of data grows for us.

There is no cloud.
Just some one else's computer.  

7 REPLIES 7

sbrnag
Mega Expert

Hi Stewe Lundin,



  GlideRecord can't be closed or terminated instead you can control the result set size by setting limit.



setLimit(int limit)


Sets the limit for how many records in the GlideRecord.


Example :




var gr = new GlideRecord('incident');


gr.orderByDesc('sys_created_on');


gr.setLimit(10);


gr.query();



The above code only gets max 10 records.
Thanks,
Nag.

This helps me in some ways, but in other issues I'm currently having.



Thanks!


Anurag Tripathi
Mega Patron
Mega Patron

Hi Steve,



I had similar challenge once and i used chooseWindow functionality of glide record(which is well hidden for some reason) to add pagination to the result set.



This will help you to navigate through the huge result but GR will still be huge, to limit that you can always use setLimit as mentioned above. And for closing the gr i would just put it in a functuion, out of the function it will not be in score, hence closed



you can find an example here, well explained


https://snprotips.com/blog/2016/9/1/gliderecord-pagination-page-through-records-with-ease


-Anurag