g_scratchpad functionality and its use
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2016 12:06 AM
Hi All,
I want to know about the use of g_scratchpad and its significance and use and its speciality.
- 71,768 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2016 12:11 AM
Hi,
The g_scratchpad object passes information from the server to the client, such as when the client requires information not available on the form. For example, if you have a client script that needs to access the field u_retrieve, and the field is not on the form, the data is not available to the client script. A typical solution to this situation is to place the field on the form and then always hide it with a client script or UI policy. While this solution may be faster to configure, it is slower to execute.
If you know what information the client needs from the server before the form is loaded, a display business rule can create g_scratchpad properties to hold this information. The g_scratchpad is sent to the client when the form is requested, making it available to all client-side scripting methods. This is a very efficient means of sending information from the server to the client. However, you can only load data this way when the form is loaded. The business rule cannot be triggered dynamically. In those cases, use an asynchronous GlideAjax call.
For example, assume you open an incident and need to pass this information to the client:
- The value of the system property css.base.color
- Whether or not the current record has attachments
- The name of the caller's manager
A display business rule sends this information to the client using the following script:
g_scratchpad.css = gs.getProperty('css.base.color');
g_scratchpad.hasAttachments = current.hasAttachments();
g_scratchpad.managerName = current.caller_id.manager.getDisplayValue();
To access scratchpad data using a client script:
// Check if the form has attachments
if (g_scratchpad.hasAttachments)
// do something interesting here
else
alert('You need to attach a form signed by ' + g_scratchpad.managerName);
Thanks,
Nitin.
PS : Mark answer as correct, helpful or like based on the impact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2018 11:30 AM
The g_scratchpad object passes information from the server to the client, such as when the client requires information not available on the form. For example, if you have a client script that needs to access the field u_retrieve, and the field is not on the form, the data is not available to the client script. A typical solution to this situation is to place the field on the form and then always hide it with a client script or UI policy. While this solution may be faster to configure, it is slower to execute.
i have seen this information in wiki , i just wondering about , if field is not available then how can we get........

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2018 05:13 AM
You are correct, placing the field on the form and then hiding it is also insecure. It doesn't take much to get to the browser tools and unhide that field.
If you don't have the field on the form and you want that information there are two choices. a) g_scratchpad to do a one-time push of the information from the server when the form is loaded, and b) a GlideAjax call to have the client script call the server and the server return a result. Async GlideAjax is recommended!
You can find out more about these in episodes 5, 6, and 33 of TechNow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2016 12:13 AM
Hi Abhinab,
The g_scratchpad object used for passing information from the server to the client when the client requires information not available on a form. This can be accomplished by creating a business rule to put the information in the g_scratchpad object and accessing the information in a client script.
For more info. refer below link:
Scripting in Business Rules - ServiceNow Wiki
Regards,
Swapnil
PS: Hit like, Helpful or Correct depending on the impact of the response