Regarding an error message while submitting a request for catalog item

apoorvaagar
Tera Contributor

Hi All,

I am using the below onSubmit catalog client script for one of the catalog item:

 

But while submitting the request, it throws as error as this : "onSubmit script error: ReferenceError: g_scratchpad is not defined:
function () { [native code] }"

 

How to fix this? 

 

function onSubmit() {
if (g_scratchpad.isFormValid)
return true;
var subscription = g_form.getValue('subscription_affected');

var subDate = g_form.getReference('subscription_affected', getRetirementDate);

function getRetirementDate(sub) {
subscription = sub.display_name;

subDate = sub.retirement_date;

}

var asset = g_form.getReference('select_the_hostname_of_the_computer', getCi);

function getCi(ci) {
asset = ci.getDisplayValue('ci');

}

var rDate = new GlideAjax('checkgroups');
rDate.addParam('sysparm_name', 'retirementDate');
rDate.addParam('sysparm_date', g_form.getValue('subscription_affected'));
rDate.getXML(cUsrBA);

return false;

function cUsrBA(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
var roundanswer = Math.round(answer);

if (roundanswer <= 30 && roundanswer > 0) {
var actionName = g_form.getActionName();
g_scratchpad.isFormValid = true;
g_form.submit(actionName);

} else if (roundanswer <= 0 || roundanswer > 30) {
if (roundanswer <= 0) {
g_form.addErrorMessage('Your admin rights on ' + asset + ' has past renewal date ' + subDate);
}
if (roundanswer > 30) {
g_form.addErrorMessage('Your admin rights on ' + asset + ' has already been renewed till ' + subDate);
}
return false;
}

}


}

 

Any inputs are appreciated.

 

Thanks.

 

 

0 REPLIES 0