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:25 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-19-2021 08:35 PM
Can we use getReference() in client script on oncellEdit() and Onsubmit()?
And Is it compulsory to use getReference() in client script only?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-19-2021 08:36 PM
yes as they are client side. Only there this will work, for backend there is other method for that.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-19-2021 08:41 PM
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