- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2016 09:34 AM
Can someone please let me know typical differences and uses of g_scratchpad and Gliderecord. Please provide some examples as well. Also please explain the below code :
To populate the form scratchpad with data from a display rule:
//from display business rule
g_scratchpad.someName = "someValue";
g_scratchpad.anotherName = "anotherValue";
//if you want the client to have access to record fields not being displayed on the form
g_scratchpad.created_by = current.sys_created_by;
//these are simple examples, in most cases you'll probably perform some other queries to test or get data
To access the form scratchpad data from a client script:
//from client script if (g_scratchpad.someName == "someValue") { //do something special }
Please let me know what is meant by the above example and if possible please provide me
some better example of passing the scratchpad value from a server to a client.
Thanks in advance!!
Regards,
Dikshit
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- 24,952 Views

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2016 10:40 AM
A GlideRecord is an object used to interact with the database. For example, if I want to retrieve all active incidents,
var inc = new GlideRecord('incident');
inc.addActiveQuery();
inc.query();
while (inc.next()) {
// Do something here
}
The g_scratchpad is an empty object you can use to push information (properties, objects, functions, etc.) from the server to the client. It is only available in display business rules and client scripts. I use it a lot to populate information on the form that is typically unavailable without an Ajax call.
When I teach this concept, I usually describe g_scratchpad as an "empty box" you can put things in for the client to open and use later.
Hope that explanation helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2016 10:40 AM
A GlideRecord is an object used to interact with the database. For example, if I want to retrieve all active incidents,
var inc = new GlideRecord('incident');
inc.addActiveQuery();
inc.query();
while (inc.next()) {
// Do something here
}
The g_scratchpad is an empty object you can use to push information (properties, objects, functions, etc.) from the server to the client. It is only available in display business rules and client scripts. I use it a lot to populate information on the form that is typically unavailable without an Ajax call.
When I teach this concept, I usually describe g_scratchpad as an "empty box" you can put things in for the client to open and use later.
Hope that explanation helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2016 10:55 AM
Forgot I wrote this a few years ago until someone liked it a few minutes ago.
https://community.servicenow.com/people/ctomasi/blog/2011/09/30/2179#comment-2313

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2016 11:02 AM
Hey, that's a fantastic link as I've had the same burning question but always just opted to use ajax calls. Thanks!