Unhandled exception in GlideAjax
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2023 07:14 PM
Actually code is working fine i got java script browser console error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2023 08:13 PM
Hi @Anish9515
In your Client Script at this line.
var parts = multilineTextVersion.split(/\),/);
It should be like below, isn't it?
var parts = multilineTextVersion.split(",");
Cheers,
Tai Vu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2023 08:18 PM
My ouput in parts is Zip 21.x (Device, EN, Win),7-Zip 22.x (Device, EN, Win),7-Zip 16 (Device, EN, Win),7-Zip 18 (Device, EN, Win),7-Zip 15 (Device, EN, Win),7-Zip 19 (Device, EN, Win),7-Zip 23.x (Device, EN, Win)
I wanna separate Zip 21.x (Device, EN, Win)
7-Zip 22.x (Device, EN, Win)
Like this
In my scenario it doesn't work
var parts = multilineTextVersion.split(",");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2023 08:26 PM
HI @Anish9515 ,
I trust you are doing great.
You can refer to below updated code for the same.
Client-Side Script
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') return;
var glideAjax = new GlideAjax('BISwCatDecomUtilAJAX');
glideAjax.addParam('sysparm_name', 'getProductVersions');
glideAjax.addParam('sysparm_sys_id', newValue);
glideAjax.getXML(handleResponse);
}
function handleResponse(response) {
try {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (!answer) throw new Error("No response received from server");
var productVersions = answer.split(/\),/);
var display = productVersions.length > 1;
g_form.setDisplay('sw_cat_item_removed', !display);
g_form.setReadOnly('sw_cat_item_removed', !display);
} catch (error) {
console.error("Error in processing GlideAjax response:", error);
// Handle the error appropriately
}
}
Server-Side Script (BISwCatDecomUtilAJAX
Script Include)
var BISwCatDecomUtilAJAX = Class.create();
BISwCatDecomUtilAJAX.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getProductVersions: function() {
var softwareId = this.getParameter('sysparm_sys_id');
var productVersions = this.fetchProductVersions(softwareId);
return productVersions.join(',');
},
fetchProductVersions: function(softwareId) {
var versions = [];
var productQuery = new GlideRecord('u_biproductgroupingproduct');
productQuery.addQuery('sys_id', softwareId);
productQuery.query();
while (productQuery.next()) {
var versionQuery = new GlideRecord('u_biproductversion');
versionQuery.addQuery('u_product_id', productQuery.u_product_id);
versionQuery.addEncodedQuery('u_product_version_status=Active');
versionQuery.query();
while (versionQuery.next()) {
versions.push(versionQuery.u_product_version_name.toString());
}
}
return versions;
},
type: 'BISwCatDecomUtilAJAX'
});
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2023 08:40 PM - edited 11-22-2023 08:44 PM
If I select a software product field that has only one version, it works fine, and if I select a software product field that has many versions, it works fine as well but i got java script console error i.e Error in processing GlideAjax response:
It's cause whenever software product keep changes in form level before submit javascript console error occurs