jcmings
ServiceNow Employee

So you can pass data from the server-side to client-side using a display business rule and the g_scratchpad object. Each item you pass (a "property") is sent as a string. Check out the below example:

 

You are on the Incident [incident] table. You create a display business rule to send over some information. Your business rule looks like this:

g_scratchpad.city = current.requested_for.city;
g_scratchpad.country = current.requested_for.country;

 

So in the above BR, we're grabbing the requestor's city and country from their User [sys_user] record. The city and country are both properties of the g_scratchpad object. 

 

You can then use a client script (any type of client script) to access that value. So your client script could do something like this...

g_form.setValue('description', 'Requestor is located in ' + g_scratchpad.city + ', ' + g_scratchpad.country);
//Output: Requestor is located in Munich, Germany

 

Long story short -- this is how we can pass server-side data to the client for usage in a client script. Some people use the scratchpad to pass a system property value to client scripts. There are various use cases!