G-Scratchpad and Getreference()

Riya
Kilo Contributor

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.

9 REPLIES 9

Riya
Kilo Contributor

Can help me to use getReference() in client script on oncellEdit() and Onsubmit()?

Basically i want oncellEdit() and Onsubmit() script code for getReference().

 

Riya
Kilo Contributor

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?

Community Alums
Not applicable

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.

Ct111
Giga Sage

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)

 

Video LINK

 

Mark my ANSWER as CORRECT and HELPFUL if it helps

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