- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2024 11:55 PM
Hi Team,
function () { [native code] }
Front of portal it's setting the variable value in below image
could pls help to resolve this error
Advance thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 01:11 AM
As far as I know g_scratchpad is not supported in CMS - only in Portal.
A workaround could be "simulating" it, something like:
function onSubmit () {
var scratchpad = getExistingScratchpad() || getCustomScratchpad();
if (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);
scratchpad.validForm = false;
}
else {
scratchpad.validForm = true;
g_form.submit();
}
});
return false;
function getCustomScratchpad () {
return NOW.g_scratchpad = NOW.g_scratchpad || {};
}
function getExistingScratchpad () {
if (typeof g_scratchpad != 'undefined')
return g_scratchpad;
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 12:53 AM
@Venky Kshatriy2 Please update the script as follows and see if it works.
function onSubmit() {
if (g_scratchpad.isFormValid) {
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.isFormValid = false;
} else {
g_scratchpad.isFormValid = true;
g_form.submit();
}
});
return false;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 01:16 AM
How is your code different from the OP's code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 02:25 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 03:15 AM
@Venky Kshatriy2 @-O- My bad, I was under the impression that there was a typo in
g_scratchpad