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

Community Alums
Not applicable

g_scratchpad is initialized only onDisplay (when you open the record by business rule) and no more access to the server so its for data that you dont excpect to be changed in a way. getReference is doing AJAX call to the DB and retrieveing the entire glide record, hence we use callback to reduce overhead.

Cheers,

Joro

Riya
Kilo Contributor

Can we use getReference() in client script on oncellEdit() and Onsubmit()?

And Is it compulsory to use getReference() in client script only?

Community Alums
Not applicable

yes as they are client side. Only there this will work, for backend there is other method for that.

Community Alums
Not applicable

For the backend this is the one to use - var rec = current.task.getRefRecord(); 

Then you can update fields in the referenced table by rec.state = 4; rec.update().

Its very handy instead doing gliderecords its just that

 

Joro