- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2025 06:01 AM
The Below Onload Client script in executing on PDI here accessing data through Glide Record. Is a expected behavior , what should be ideal case for glide Record in client side , is through error or provide output .
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2025 06:28 AM
@darshan-pra it would work in Native UI but not in portal, scoped app or mobile as mentioned by @Ankur Bawiskar.
The GlideRecord API is the primary means of interfacing with the database on the server-side code. Its best not to mix server side APIs with client scripts as it could break in Service Portal, mobile and future upgrades. Use best practices so that your code is scalable and optimised. ServiceNow has GlideAjax class to call server side script from client side and fetch necessary data, you can make use of it.
Regards,
Ehab Pilloor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2025 06:06 AM - edited 07-01-2025 06:14 AM
Hi @darshan-pra,
Your script is using server-side GlideRecord in a client script, which is not recommended in ServiceNow. Best practice is to avoid using GlideRecord directly in client scripts because it runs on the server. Instead, use GlideAjax to call a Script Include on the server from your client script. This way you can safely retrieve server side data like Incident records while keeping the client and server logic separated.
Regards,
Ehab Pilloor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2025 06:13 AM
That but here i am getting result without throwing any error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2025 06:28 AM
@darshan-pra it would work in Native UI but not in portal, scoped app or mobile as mentioned by @Ankur Bawiskar.
The GlideRecord API is the primary means of interfacing with the database on the server-side code. Its best not to mix server side APIs with client scripts as it could break in Service Portal, mobile and future upgrades. Use best practices so that your code is scalable and optimised. ServiceNow has GlideAjax class to call server side script from client side and fetch necessary data, you can make use of it.
Regards,
Ehab Pilloor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2025 06:10 AM
you can use GlideRecord in client side but it's not recommended.
It won't work in portal and scoped app as it's not allowed
Also GlideRecord on client side has some limitations and not all methods can be used.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader