g_scratchpad

Keshav5
Kilo Contributor

Hi Team, 

Can someone explain me where the value is displayed in the form after we retrieve the value from g_scratchpad using client script, NOTE: g_scratch pad is used to get the value from the server which is not there in the client end. So after we get the value from g_scratchpad will it create a field in the client form to display the value which is fetched from the g_scratchpad or this will display like a popup. 

Also want to know if there is client/server synchronization then why we cannot directly pull the info using client script rather than using g_scratchpad.?

8 REPLIES 8

It could be anything really. If there is information about the record you are loading that you want to have available to your client scripts right away and you don’t want to have to use an AJAX call to get it, you can setup an on display business rule to set that property on g_scratchpad, and that will be available on the client. You could set up an on display rule that just does this: g_scratchpad.myTestData = “hello world”; The in an onload client script on that same table, you can put this and it will output “hello world” at the top of the form: g_form.addInfoMessage(g_scratchpad.myTestData);

Keshav5
Kilo Contributor

All the information in a client form is displayed from the server, even all the values are also stored in the server, so why there is special case for the usage of g_scratchpad, In the above code you can display the message by using i

f(newvalue=='true')

alert("helloworld")

This is also possible

 

Can you read through this DOC and see if it answers your question? https://docs.servicenow.com/bundle/geneva-servicenow-platform/page/app-store/good_practices/client_script/reference/r_ServerDataExampleScratchpad.html

Keshav5
Kilo Contributor

Really sorry that i am behind you, just not getting the right point.

Please understand me,

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);

The value of the system property css.base.color ( does this mean that client requested the system properties via incident)
Whether or not the current record has attachments ( Why the user want to know the curent record has attachment )
The name of the caller's manager( what is the scenario behind these request, why the end user needs this information )

What is the purpose behind this script written, In the end user perspective can you please tell me because I am just a user who have the access to servicenow instance,