Why is GlideRecord not available in ClientScript in the Custom Application scope?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2023 11:49 PM
The following error occurred when using GlideRecord within a ClientScript created in a scope application.
Error:「onChange script error: TypeError: GlideRecord is not a constructor function () { [native code] }」
I believe the error is due to the use of GlideRecord within the ClientScript created in the custom scope application.
I would appreciate a technical explanation. (Because it crosses a scope boundary?)
Also, if I create a GlideRecord part in a ScriptInclude and call that ScriptInclude from ClientScript, I no longer get the above error, but why is the error no longer occurring?
Please let us know.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2023 01:01 AM
please understand the difference between server-side code where GlideRecord API is located and client-side code which is running only in the browser. Yes, it is possible to use a GlideRecord API on client-side, but it is not recommended.
And without more details from your side (where is the code example?) it's possible to help you.
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2023 01:08 AM
Client-side GlideRecord is massively inefficient, far too slow, and returns way too much unnecessary data to be used commonly in production code. GlideAjax is simply the best and most efficient method for looking up data from client-side scripts.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2023 01:15 AM
Hello @Takakazu Sato ,
Yes GlideRecord API is available on client scripts but it is not at all recommended to use a GlideRecord API in client side .You need to minimise server calls to avoid the performance issue
GlideRecord and g_form.getReference() callback are also available for retrieving server information. However, these methods are no longer recommended due to their performance impact. Both methods retrieve all fields in the requested GlideRecord when most cases only require one field. The GlideRecord API is not available for scoped applications.
See the points highlighted in red .For scoped or custom apps glide record api is not available on client scripts and this is the reason you are getting this error .So only way is to call a script include via GlideAjax.
For more best practices on client scripts follow this link
Hope this helps
Mark the answer correct if this helps you
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2023 02:56 AM
Thanks for the reply.
Please tell me one thing: GlideRecord API is not available in ClientScript for scoped custom applications.
Why is the GlideRecord API not available in ClientScript for custom applications? I would like to know the technical background.