g_scratchpad is not working in on change client script

suyogd
Tera Contributor

Hello All,

g_scratchpad is not working in on change client script. I am taking class name of configuration item and storing in scratchpad variables and calling that variable in client script but it is not working. There is display BR written on incident table.

in BR

g_scratchpad.variable_name = current.cmdb_ci.sys_class_name

in on change client script

if(g_scratchpad.variable_name != 'app_instance'){

g_form.setValue('variable_name',value);

but it is not working could anyone give suggestion am i doing anything wrong here ?

1 ACCEPTED SOLUTION

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

g_scratchpad will hold the value if the CMDB_CI field is already populated when the form was loaded. If this is the exact case you are trying then it should work. Also note the value will not be populated in g_scratchpad dynamically i.e when the field CMDB_CI field is populated without saving the form. In that case, you will have to make a GlideAjax call from the client side.

 

-Pradeep Sharma

View solution in original post

2 REPLIES 2

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

g_scratchpad will hold the value if the CMDB_CI field is already populated when the form was loaded. If this is the exact case you are trying then it should work. Also note the value will not be populated in g_scratchpad dynamically i.e when the field CMDB_CI field is populated without saving the form. In that case, you will have to make a GlideAjax call from the client side.

 

-Pradeep Sharma

Thank you Pradeep. It is working fine by using GlideAjax.