G-Scratchpad and Getreference()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-19-2021 08:19 PM
Can anyone explain me the difference between G-Scratchpad and Getreference() in servicenow? when to use G-Scratchpad and when to use Getreference()? Please explain with example.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-19-2021 08:40 PM
Can help me to use getReference() in client script on oncellEdit() and Onsubmit()?
Basically i want oncellEdit() and Onsubmit() script code for getReference().
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-19-2021 08:43 PM
I want an example with some situation where we have to use getReference() only instead of G-Scratchpad?
i.e in what situation we have to use getReference() only?
and in what situation we have to use G-Scratchpad?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-19-2021 08:54 PM
Any client srit doing manipulation/retrieving data from related tables (by the reference field we use) should use getReference(). For anything that you need to pass to the client side but from the record loading (in the very start) you better use g_scratchpad. For exampla I use g_scratchpad when using UI Pages and I call them from UI Action. There are some use cases where you need g)scratchpad. Open the business rules for incident or tasks table and serach for BRule onDisplay(0 -you will see how SN is using g_sratchpad.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-19-2021 09:18 PM
I will tell you from my experience where i have used both
g_scratchpad I have used in two places frequently one is in workflow and one is in display business rule.
The idea of g_scratchpad is to store the value somewhere and access it when required in your code
like incase of business rule you use g_scratchpad and then access that value in client and incase of workflow
you use that value to store some data in temporary varialbe which you can access further in any script or
notification
g_scratchpad example video link
And the use of getReference () was done in client script to call any reference value rather than
than writing the gliderecord entire script for that table...
However use it carefully as it has some performance implication when used wrongly
Check the example link
Callback Function (get reference)
Mark my ANSWER as CORRECT and HELPFUL if it helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-19-2021 11:03 PM
Thanks,
If my ANSWER helped you in achieving your objective could you please
mark it as CORRECT as well so that anyone in future with same query will be
benefited from it