Getting error in g_scratchpad

arunkumar119909
Tera Contributor

Hi team,

 

function onSubmit() {

    if (g_scratchpad.validForm) {
        return;
    }

    var reason1 = g_form.getValue('reason1');
    var reason2 = g_form.getValue('reason2');

    var mrvs = g_form.getValue('risk_rating_from_country');

    var vk = new GlideAjax("Decision_table_risk_rating");
    vk.addParam('sysparm_name', 'getriskratings');
    vk.addParam('sysparm_from', g_form.getValue('from'));
    vk.addParam('sysparam_to', g_form.getValue('to'));
    vk.addParam('sysparam_mrvs', mrvs);

    vk.getXML(function risk(response) {

        var answer = response.responseXML.documentElement.getAttribute("answer");
        alert('risk rating' + answer);
        g_form.setValue('risk_rating', answer);
        if (answer == 1 && reason1 == '' && reason2 == '') {
            g_form.setVisible('reason1', true);
            g_form.setVisible('reason2', true);
            g_form.setMandatory('reason1', true);
            g_form.setMandatory('reason2', true);
            g_scratchpad.validForm = false;
        } else {
            g_scratchpad.validForm = true;
            g_form.submit();
        }
    });
   
    return false;


}
 
 
Above mentioned code i am used to call the script include to on submit client script 
front of the serviceportal it's working fine i am getting value and it's to variable but
If i used the in catalog item we have a TRYIT UI action if use this button and test it after i am getting the bellow error
onSubmit script error: ReferenceError: g_scratchpad is not defined:
function () { [native code] }
arunkumar119909_0-1721800867268.png

 below diagram is front end of portal

arunkumar119909_1-1721800930112.png

Team  Help me to resolve this issue

1 REPLY 1

Bhavya11
Kilo Patron

Hi @arunkumar119909 

 

Please use below link :

https://www.servicenow.com/community/itsm-forum/issue-in-g-scratchpad-using-on-submit-client-script/... 

 

Please mark helpful & correct answer if it's really worthy for you.

 

 

Thanks,

BK