Scratchpad is not defined error

Vikram Vasudev
Tera Contributor

Hello All, 

When i am calling server side code in client side onsubmit client script its throwing error scratchpad is not defined i am using isformValid method still i am facing issue. 

Thanks in Advance. 

1 ACCEPTED SOLUTION

Anand Kumar P
Giga Patron
Giga Patron

Hi @Vikram Vasudev,

g_scratchpad.isFormValid is true. If it is, the form submission proceeds. Otherwise, it uses GlideAjax to make an asynchronous request and sets a callback function to handle the response. Upon receiving the response, it sets g_scratchpad.isFormValid to true and resubmits the form with the original actionName. This approach ensures that the asynchronous behavior doesn’t interfere with form submission.
function onSubmit() {
if (g_scratchpad.isFormValid){
return true;
}
var actionName = g_form.getActionName();
var ga = new GlideAjax("SOMEFUNCTION");
ga.addParam(.....);
ga.getXML(function() {
g_scratchpad.isFormValid = true;
g_form.submit(actionName);
});
return false;
}
 Please mark it as solution proposed and helpful if it works for you.

Thanks,

Anand

View solution in original post

1 REPLY 1

Anand Kumar P
Giga Patron
Giga Patron

Hi @Vikram Vasudev,

g_scratchpad.isFormValid is true. If it is, the form submission proceeds. Otherwise, it uses GlideAjax to make an asynchronous request and sets a callback function to handle the response. Upon receiving the response, it sets g_scratchpad.isFormValid to true and resubmits the form with the original actionName. This approach ensures that the asynchronous behavior doesn’t interfere with form submission.
function onSubmit() {
if (g_scratchpad.isFormValid){
return true;
}
var actionName = g_form.getActionName();
var ga = new GlideAjax("SOMEFUNCTION");
ga.addParam(.....);
ga.getXML(function() {
g_scratchpad.isFormValid = true;
g_form.submit(actionName);
});
return false;
}
 Please mark it as solution proposed and helpful if it works for you.

Thanks,

Anand