can we use g_scratchpad variables from one client script to other client script , please give examples doc, link etc?

mallikharjunasw
Tera Contributor

can we use g_scratchpad variables from one client script to other client script , please give examples doc, link etc?

1 ACCEPTED SOLUTION

Hi,

Nope; you can only define scratchpad in display business rule and not in any other place either business rule of client script

once defined in display business rule you can use it in different client scripts such as onload, onchange, onsubmit

Sample Interview questions

1) What is the use of scratchpad in servicenow

2) Can it be used in other scripts such as business rule - no

3) can it be used in client scripts such as onload, onchange, onsubmit- yes

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

g_scratchpad variable should be defined in display business rule and then it can be used in all client scripts such as onload, onchange, onsubmit etc

display business rule:

g_scratchpad.assignment_group = current.getDisplayValue('assignment_group');

you can then use this in client script as below

function onLoad(){

alert(g_scratchpad.assignment_group);

}


Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

 same g_scratchpad variable can be used in different client scripts, right?

Can we define the g_scratchpad variable in any type of scripts other than the Display Business Rule?

what are the different interview questions possible on g_scratchpad variable?

Hi,

Nope; you can only define scratchpad in display business rule and not in any other place either business rule of client script

once defined in display business rule you can use it in different client scripts such as onload, onchange, onsubmit

Sample Interview questions

1) What is the use of scratchpad in servicenow

2) Can it be used in other scripts such as business rule - no

3) can it be used in client scripts such as onload, onchange, onsubmit- yes

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Does scratchpad definition works for Display business Rule for all the insert, update, delete and query operations or is there an exception?