OnChange in catalog Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2024 08:56 AM
Am using onchange catalog client script for portal and using GlideAjax call.
when I load the page and change the field am getting "ErrorThere is a JavaScript error in your browser console"
Please guide me best practices
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2024 09:02 AM
Please attach code here, so that we can suggest you appropriate solution.
Regards
Faiz
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2024 06:53 AM
Hi @Faiz Ahmed Moha Please check the snipped code below
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var emsg = new GlideAjax('Customer');
emsg.addParam('sysparm_name', "ErrorMessages");
emsg.getXMLWait();
var answer = emsg.getAnswer();
var errMsg = JSON.parse(answer);
var gaAJAX = new GlideAjax('Utilities');
gaAJAX.addParam('sysparm_name', "cal");
gaAJAX.addParam('sysparm_asset', g_form.getValue(‘abc’));
gaAJAX.getXML(test);
function test(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer == 'error') {
g_form.setValue(‘abc’, 'false');
g_form.setValue(‘abc’, 'true'); //asset
getMessage(errMsg.ahc, function(msg) {
g_form.showFieldMsg('testfield', msg, 'error');
});
} else {
g_form.setValue(‘ab’, 'false');
g_form.setValue(‘xyz’, 'false');
getMessage(errMsg.failed, function(msg) {
g_form.addErrorMessage(msg);
});
}}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2024 07:51 AM
Hi @String, Could you please confirm if this client script working fine in Desktop/Platform view but not in portal ?
Regards
Faiz