- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-18-2022 08:54 AM
Hello All,
I have written a catalog client script and script include nut getting an error message.
There is a JavaScript error in your browser console
Unhandled exception in GlideAjax in Service Portal
Please let me know how can I solve this.
Client script :
function onSubmit () {
var actionname = g_form.getActionName();
var scratchpad = typeof g_scratchpad == 'undefined' ? NOW : g_scratchpad;
if (scratchpad.isSupportGroup) {
return true;
}
var val = g_form.getValue('datacity_service');
var ga = new GlideAjax('DataCityRequest');
ga.addParam('sysparm_name', 'populateApplicationFields');
ga.getXMLAnswer(populateApplicationFields);
return false;
function populateApplicationFields(response) {
var answer = response.responseXML.documentElement.getAttribute('answer');
var obj = answer.evalJSON(true);
var PV_Corporate_Request = obj.property1.split(",");
var PV_Customer_Request = obj.property2.split(",");
var PV_Operations_Request = obj.property3.split(",");
var AppropriateCategory = g_form.getValue('appropriate_category');
if ((AppropriateCategory == 'Request Enhancement') || (AppropriateCategory == 'SME-Project Estimates') || (AppropriateCategory == 'Report Defect')) {
if (PV_Corporate_Request.indexOf(val) > -1) {
g_form.setValue('support_group', 'DWBI-Corporate-Requests');
scratchpad.isSupportGroup = true;
}
else if (PV_Customer_Request.indexOf(val) > -1) {
g_form.setValue('support_group', 'DWBI-Customer-Requests');
scratchpad.isSupportGroup = true;
}
else if (PV_Operations_Request.indexOf(val) > -1) {
g_form.setValue('support_group', 'DWBI-Operations-Requests');
scratchpad.isSupportGroup = true;
}
else {
g_form.setValue('support_group', 'ITDS-BI-REQUESTS');
scratchpad.isSupportGroup = true;
}
scratchpad.isSupportGroup = true;
g_form.orderNow(actionname);
}
else {
g_form.setValue('support_group', 'ITDS-BI-REQUESTS');
scratchpad.isSupportGroup = true;
g_form.orderNow(actionname);
}
}
}
script include:
var DataCityRequest = Class.create();
DataCityRequest.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
populateApplicationFields: function() {
var obj = {};
obj.property1 = gs.getProperty("Datacity Request - DWBI-Corporate-Requests");
obj.property2 = gs.getProperty("Datacity Request - DWBI-Customer-Requests");
obj.property3 = gs.getProperty("Datacity Request - DWBI-Operations-Requests");
return JSON.stringify(obj);
},
type: 'DataCityRequest'
});
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-18-2022 10:53 AM
Yeah, me silly, the reference to the function(s) need to be "bound" as below:
var submitMethod = typeof g_form.orderNow == 'function' ? g_form.orderNow.bind(g_form) : g_form.submit.bind(g_form);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-18-2022 09:00 AM
If you use getXMLAnswer
var answer = response.responseXML.documentElement.getAttribute('answer');
is invalid/not necessary.
You can directly write:
var obj = JSON.parse(response);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-18-2022 09:01 AM
In other words:
function populateApplicationFields (response) {
//var answer = response.responseXML.documentElement.getAttribute('answer');
var obj = JSON.parse(response);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-18-2022 09:04 AM
Hello Janos,
Still same.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-18-2022 09:15 AM
Hello Janos,
still getting the error.
Thanks