CAD · Question #253
What is the correct use of g_scratchpad in a ServiceNow client script?
The correct answer is A. To store temporary server-side variables that can be accessed from the client. The g_scratchpad object is used in ServiceNow to transfer temporary server-side data from a Display Business Rule to a client script when a form loads.
Question
What is the correct use of g_scratchpad in a ServiceNow client script?
Options
- ATo store temporary server-side variables that can be accessed from the client.
- BTo reference data in the global scope for client-side scripting.
- CTo execute server-side functions in client scripts.
- DTo maintain session data for users.
How the community answered
(53 responses)- A89% (47)
- B4% (2)
- C2% (1)
- D6% (3)
Why each option
The `g_scratchpad` object is used in ServiceNow to transfer temporary server-side data from a Display Business Rule to a client script when a form loads.
`g_scratchpad` serves as a temporary object populated by a Display Business Rule on the server-side, allowing it to pass non-field data to client scripts for use when the form loads, thus facilitating server-to-client data transfer.
While `g_scratchpad` is a global client-side object, its specific purpose is for data transfer from server to client, not for referencing arbitrary global scope data.
`g_scratchpad` is for data transfer, not for executing server-side functions; `GlideAjax` is typically used for calling server-side functions from client scripts.
`g_scratchpad` data is transient and specific to a single form load, making it unsuitable for maintaining long-term user session data.
Concept tested: g_scratchpad for server-to-client data transfer
Source: https://docs.servicenow.com/bundle/utah-application-development/page/script/client-scripts/concept/g_scratchpad_reference.html
Topics
Community Discussion
No community discussion yet for this question.