how we can use g_scratchpad in business rule and workflow ?

Savita P
Tera Contributor

how we can use g_scratchpad in business rule and workflow ?

1 ACCEPTED SOLUTION

AbhishekGardade
Giga Sage

Hello Hit,

#g_scratchpad:  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.

 

  1. The g_scratchpad is an empty object you can use to push information (properties, objects, functions, etc.) from the server to the client. It is only available in display business rules and client scripts.
  2. It’s a one directional process, server to client
  3. It is only available in display business rules and client scripts. I use it a lot to populate information on the form that is typically unavailable without an Ajax call.
  4. Workflow activities:
    1. scratchpad.variableName = variableValue;
    2. var myValue = workflow.scratchpad.variableName;

Example:

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

For detailed information about it:

https://servicenowgems.com/2016/10/10/understanding-scratchpad-g_scratchpad/

Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade

 

Thank you,
Abhishek Gardade

View solution in original post

5 REPLIES 5

Ansh Mahajan
Tera Contributor

Hi @AbhishekGardade 

 

can we use g_scratchpad value for 2 different tables like what if i want to populate first reported by field available on problem form with incident? is it possible with this?

 

Thanks

Ansh Mahajan