
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 12-18-2018 11:23 PM
Hi Folks,
Definition of g_scratchpad ::
The g_scratchpad is an empty object we can use to store information (properties,
objects, functions, etc.) from the server side script to the client. It is only available in display
business rules and client scripts.
Suppose we are using server side script and call that script by glide Ajax in client side.For example
there are times when i need some server side information on the client side and for some reason
we are calling server side script from an Ajax call .By using the g_scratchpad object, I'll show
you how to call server side script functions to "set up" information that the client script can consume.
Here is an example based on a customer requirement, present an alert message when an emergency change
request is in the state "Somthing", and has no attachment.
Wouldn't it be nice if there was a client side function to detect if there are attachments on a record?
I thought, there's an easy way to do this. From the server side, we can use
current.hasAttachments()
g_scratchpad object is returning the Boolean value True/False(true=this record has attachments, false= this
record has no attachments found.). Using the g_scratchpad object, we can store
that value and pick it up with a client script. This is a great place to use a display business rule to do the
set up.
Lets we are using the g_scratchpad in the code::
Step 1. write business rule :
Name: Check_hasAttachments
Table: Change Request [change_request]
When to run: display
Script:
// Check for attachments and save it in the g_scratchpad variable
//this is user define variable get_HasAttachments
g_scratchpad.get_HasAttachments = current.hasAttachments();
Step 2. write client script in onLoad Condition :
Name:check_HasAttachment_by_Alert
Type: onLoad
Table: Change Request [change_request]
Script:
function onLoad() {
if (g_form.getValue('type') == 'Emergency' && !g_scratchpad.hasAttachments) {
alert("Please attache you attachments");
}
}
You can go to Docs link also: GlideForm ScratchPad
Here you'll find uses for the g_scratchpad and establish the communication more effectively
between your server side script and client scripts.
I hope it is helping a lot for beginners and others also .
- 18,296 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
does g_scratchpad also works on OnChange and onSubmit Client scripts

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Yes it will work
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Sanjay,
As you told, g_scracthpad will aslo work in 'On submit CS' . I am using below mentioned script but it is not working. Can you help me.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hello @HussainBasB
On which table are you creating this Business Rule.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
I created this full live demo on how to use g_scratchpad object. hope this helps 🙂

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
BTW: g_scratchpad is also a great way to add scripts that need to be called from several other scripts.
So in an onLoad Script you can put something like
g_scratchpad.checkFunction = function()
{
// Perform checks
}
And then you can use this in all Client Scripts of the given Catalog Item or Variable set.