g_scratchpad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-23-2025 07:52 AM
I am new to ServiceNow and trying to learn client scripts
can someone explain about g_scratchpad in details
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-23-2025 10:34 AM
Hi @Community Alums ,
g_scratchpad is a special object in ServiceNow that allows you to pass data from server-side scripts (specifically display business rules) to client-side scripts. This is particularly useful when you need to use server-side information in your client scripts without making additional server calls.
you can refer below blogs
and youtube video
https://www.youtube.com/watch?v=77D7DMIaG24
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-23-2025 03:04 PM - edited ā04-23-2025 03:05 PM
So you can pass data from the server-side to client-side using a display business rule and the g_scratchpad object. Each item you pass (a "property") is sent as a string. Check out the below example:
You are on the Incident [incident] table. You create a display business rule to send over some information. Your business rule looks like this:
g_scratchpad.city = current.requested_for.city;
g_scratchpad.country = current.requested_for.country;
So in the above BR, we're grabbing the requestor's city and country from their User [sys_user] record. The city and country are both properties of the g_scratchpad object.
You can then use a client script (any type of client script) to access that value. So your client script could do something like this...
g_form.setValue('description', 'Requestor is located in ' + g_scratchpad.city + ', ' + g_scratchpad.country);
//Output: Requestor is located in Munich, Germany
Long story short -- this is how we can pass server-side data to the client for usage in a client script. Some people use the scratchpad to pass a system property value to client scripts. There are various use cases!