what is scratch pad?

sreenivassinsta
Tera Contributor

what is scratch pad, 

what is its use in business rules , client scripts, ui policies , workflows?

what is difference between scratchpad and ajax in clientscripts ?

1 ACCEPTED SOLUTION

Ashutosh Munot1
Kilo Patron
Kilo Patron

Hi,

 

Scratch pad is the temparory variable that can be used in workflows, BR and client scripts.

 

When we use the scratchpad in workflows we initiate it using below syntax:

workflow.scratchpad.abc = current.caller_id; you can anything instead of abc and assign any value to this scratchpad and use this scratchpad value in anyother activity in the same workflow as below :

gr.setValue('requested_for',workflow.scratchpad.abc);

 

Now when you use this scratchpad variable in BR then we initiate this object as below:

g_scratchpad.group = current.assignment_group; This should be used in Display BR and then we can use this scratchpad variable in client script as below:

g_form.setValue('fieldname',g_scratchpad.group);

 

Now coming to last question: Ajax is a proper may of calling a script include into client script and getting values from server which runs when we call it.

 

Display BR runs on load of a form, so this scratchpad value is available for you when the form loads. you can also do ajax call onload.


Thanks,

Ashutosh Munot

View solution in original post

6 REPLIES 6

Hi Sreenivas,

Forgot to give you a picture on Glide Ajax vs. g_scratchpad.

 

 

Third case, scratchpad is just a global variable and on contrary the Ajax is a server call, its a method altogether. Example for a Ajax client script is given below:

Two types of Ajax calls are available:

Type 1 synchronous: meaning execution steps gets completed before giving control to the user -

var ga = new GlideAjax('HelloWorld') ;

ga.addParam('sysparm_name','helloWorld');

ga.addParam('sysparm_user_name',"Bob");

ga.getXMLWait();

alert(ga.getAnswer());



Type 2 asynchronour: meaning a separate execution takes at back end while giving the control to the user even before total execution of the code.

First remember a standard line used in every ajax call -

1.Used in the call back function - var answer = response.responseXML.documentElement.getAttribute("answer");

Script for onChange:

 
var ga = new GlideAjax('HelloWorld');
ga.addParam('sysparm_name', 'helloWorld');
ga.addParam('sysparm_user_name', "Bob");
ga.getXML(HelloWorldParse);
 
function HelloWorldParse(response) {
  var answer = response.responseXML.documentElement.getAttribute("answer");
  alert(answer); }

Thanks, Akash

Regards, Akash
If my response proves useful, please mark it "Accept as Solution" and "Helpful". This action benefits both the community and me.

JAYESH KUMAR YA
Tera Contributor

A Scratchpad is an empty object which is used to push data from Server-side to Client-side .

Always written on Display Business Rule. 

We can use it to populate the data from server-side to client form.

Eg :

In this scenerio i'll get the caller's email and set it to the client's Form.

 

 

Declaring the Scratchpad(On Display in Business Rule) :

 g_scratchpad.caller_email =  current.u_caller.email ; 

 

Accessing it in Client Script :

g_form.setValue("u_email" ,  g_scratchpad.caller_email) ;