Is there any performance issue of using Glide Reco... - ServiceNow Community

Is there any performance issue of using Glide Record in client script??

Ct111
Giga Sage

Hi Friends,

Hope you all are good. I had a question that if we use Glide Record in Client script is there any performance issue

when the number of records existing at the prod instance is high . 

        I saw the usage of GLide Record in client script from Servicenow doc , and to me currently there are no issues in DEV environment  but I would like to know your opinion  regarding the same , as our project is going to be live in few days and I need to look upon it

 

5 REPLIES 5

Dubz
Mega Sage

Yes is the short answer!

 

If you call a glide record in a client script, or use getReference, it will call the server and return the entire record to the client. Obviously, if you only need one value from that record this is a significant processing overhead that is completely unnecessary!

 

As an analogy: if you're at a buffet and you have your eye on the cheesecake for desert, gliderecord and getreference are the equivalent of going over to the buffet and bringing the whole desert trolley back over to your table in order to serve yourself a slice of cheesecake, rather than just going up and getting a single slice of cheesecake.

 

Best practice is to call the server using Glide Ajax and using a script include to run the glide query return the data you actually need.

 

On a similar note, if you're setting the value of a reference field in a client script, if you only provide it with a sys_id it will go ahead and make a call to the server to retrieve the display value. I don't have a food related analogy for this but if you have used a glide record to get a sys_id and you then use that to set the value you're calling the server to retrieve the whole record, taking one value from that record and then calling the server again to confirm the display value.

 

These overheads may not be noticeable at first but they have a habit of building up and before you know it your users are getting irate and the slow forms they have to interact with.

 

Cheers

Dave

Ct111
Giga Sage

but if you write Script Include that will also go to the server for processing and client script as well , what my question is if there was a performance issue problem due to this then why Servicenow gave the option of including GlideRecord in client script at first place .

 

And I can see the example in Kingston doc as well that we can put GLideRecord in client :

https://docs.servicenow.com/bundle/kingstonapplicationdevelopment/page/appstore/dev_portal/API_reference/GlideRecordClientSide/concept/c_GlideRecordClientSideAPI.html

 

Note : We are already putting filter on GlideRecord() in client script that will give us value as per that so what's the issue then.

 

Client side GlideRecords and getReference() are still possible but not recommended due to the performance impact i explained in my original message. In an ideal world you would only use information available in the client in your client scripts, you can facilitate this by populating the g_scratchpad with data using a display business rule. However if you need to use a glide record, doing the processing on the server is much more efficient as you can target only the data you require rather than transferring a whole record to the client.

 

You can still use glide records and getReference() in the client but it's important to bear in mind the potential performance impact. I suppose that's what best practices are all about, it's up to you how much you adhere to them.

Ct111
Giga Sage

Anyone please help,

 

And also provide a Sample Example of Glide Record used in Script Include and called from CLient script.;