- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2020 09:52 AM
I would like to reference the number of rows from a related list in a client script. I don't know if any variables/system attributes exist that would allow me to do that? For example, can a client script reference the number of child incidents associated with the current incident without having to do queries, etc.? The only way I know of is to go GlideRecord and run the same query to get my count back. But am wondering if there is an easier more straight forward way of accessing this information?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2020 09:55 AM
I would suggest using a display business rule to do the counting, put the count in the g_scratchpad object and have the client script use that. Far more efficient to push the count to the client than have the client request the count from the server (one way trip instead of round trip.)
Avoid using GlideRecord queries on client scripts. That's been identified as a bad practice. If you MUST get dynamic data consider using GlideAjax, but this particular use case doesn't feel like that.
Example - retrieve server data using g_scratchpad | ServiceNow Docs

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2020 09:53 AM
Hi Brian,
Yes, you are right. You have to GlideRecord the target table to get the count of records.
- Pradeep Sharma

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2020 09:55 AM
I would suggest using a display business rule to do the counting, put the count in the g_scratchpad object and have the client script use that. Far more efficient to push the count to the client than have the client request the count from the server (one way trip instead of round trip.)
Avoid using GlideRecord queries on client scripts. That's been identified as a bad practice. If you MUST get dynamic data consider using GlideAjax, but this particular use case doesn't feel like that.
Example - retrieve server data using g_scratchpad | ServiceNow Docs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2020 09:56 AM
Thanks Chuck and Pradeep, appreciate the help!