Any UseCase of g_scratchPad in servicenow??

SandeepKSingh
Kilo Sage
 
3 ACCEPTED SOLUTIONS

Abhay Kumar1
Giga Sage

@SandeepKSingh In ServiceNow, g_scratchpad is a special object used to store temporary data that can be accessed across client-side and server-side scripts within the same transaction. It is often used in UI Scripts, UI Actions, Business Rules, Client Scripts, and Script Includes to pass data between scripts, especially when there is a need to share data across different script types in a single transaction.

Scenario: You want to retrieve a user's Manager and Department information on the server-side (via a Business Rule) and pass this information to a Client Script to dynamically display it on the form.

There are many articles to explain with code as well just search in community.

 

View solution in original post

Rajesh Mushke
Mega Sage
Mega Sage

Hi @SandeepKSingh,

 

Refer the below video to understand the use case easily. It is very well demonstrated in the video.

https://www.youtube.com/watch?v=LclUuP-gSNw 

https://www.youtube.com/watch?v=77D7DMIaG24 



Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke

View solution in original post

In this video, you will learn three ways of getting data from server on Client. You will learn about: - g_scratchpad - getReference() - GlideAjax Our Website: https://www.saaswithservicenow.in Our Facebook Page : https://www.facebook.com/saaswithservicenow Our Discord: https://discord.gg/mcevNeE ...
g_scratchpad object is used to pass information from service to client. I this video i have provided the brief demo that how we can use g_scratchpad in servicenow and how we can use g_scratchpad object in display business rule (server side) and in client script (client side). Please visit below ...

Ravi Gaurav
Giga Sage
Giga Sage

Refer :- https://www.servicenow.com/community/developer-forum/g-scratchpad-functionality-and-its-use/m-p/1772...

--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

ï”— YouTube: https://www.youtube.com/@learnservicenowwithravi
ï”— LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/

View solution in original post

5 REPLIES 5

Abhay Kumar1
Giga Sage

@SandeepKSingh In ServiceNow, g_scratchpad is a special object used to store temporary data that can be accessed across client-side and server-side scripts within the same transaction. It is often used in UI Scripts, UI Actions, Business Rules, Client Scripts, and Script Includes to pass data between scripts, especially when there is a need to share data across different script types in a single transaction.

Scenario: You want to retrieve a user's Manager and Department information on the server-side (via a Business Rule) and pass this information to a Client Script to dynamically display it on the form.

There are many articles to explain with code as well just search in community.

 

Valmik Patil1
Kilo Sage

Hello @SandeepKSingh ,

 

g_scratchPad is temporary variable used to pass data from server to client.

Use case : There should be at least one attachment available on the form.

- In this case we should write display BR to get if attachment is available or not.

- We can access variable in client script and give alert to user that "no attachment present "

Refer below article for details,

https://www.servicenow.com/community/itsm-articles/quot-use-of-server-side-script-g-scratchpad-and-c...

 

Thanks,

Valmik Patil

dgarad
Giga Sage

Hi @SandeepKSingh 

Please refer the below link.

https://www.servicenow.com/community/developer-forum/g-scratchpad-functionality-and-its-use/m-p/1772...

If my answer finds you well, helpful, and related to the question asked. Please mark it as correct and helpful.

Thanks
dgarad

Rajesh Mushke
Mega Sage
Mega Sage

Hi @SandeepKSingh,

 

Refer the below video to understand the use case easily. It is very well demonstrated in the video.

https://www.youtube.com/watch?v=LclUuP-gSNw 

https://www.youtube.com/watch?v=77D7DMIaG24 



Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke
In this video, you will learn three ways of getting data from server on Client. You will learn about: - g_scratchpad - getReference() - GlideAjax Our Website: https://www.saaswithservicenow.in Our Facebook Page : https://www.facebook.com/saaswithservicenow Our Discord: https://discord.gg/mcevNeE ...
g_scratchpad object is used to pass information from service to client. I this video i have provided the brief demo that how we can use g_scratchpad in servicenow and how we can use g_scratchpad object in display business rule (server side) and in client script (client side). Please visit below ...