Client catalog script stopped working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2023 09:28 AM
XML Response: <ml answer="Apple MacBook Pro, Apple Magic Keyboard with Numeric Keypad, Mouse, Headset | |1509aa4387b79d10d1d5cb7eebb35b5, 71d96a4387b79d10d1d5cb7edebb35be, 9ee9668387b79d10d1d5cb7e@ebb352a, c9f9668387b79d10d1d5cb7edebb35 e5" sysparm max="15" sysparm name="options" sysparm processor="findOptions"></xml>
Answer: Apple MacBook Pro,Apple Magic Keyboard with Numeric Keypad, Mouse, Headset ||1509a4387b79d10d1d5cb7edebb35b5,71d96a4387b79d10d1d5cb7edebb35be,9ee9668387b79d10d1d5cb7e0ebb352a, c9f9668387b79d10d1d5cb7e0ebb355
In the prod instance it gives me the following XML response:
XML Response: <xml sysparm_max="15" sysparm_name="options" sysparm_processor="findOptions"></xml>
Answer: null
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var bundleSelected = g_form.getValue('u_bundle');
var ga = new GlideAjax('findOptions');
ga.addParam('sysparm_name', 'options');
ga.addParam('sysparm_u_bundle', bundleSelected);
ga.getXML(doSomething);
}
function doSomething(response) {
var xmlResponse = response.responseXML.documentElement;
var answer = xmlResponse.getAttribute('answer');
// Log the XML response and answer for debugging
console.log('XML Response:', xmlResponse);
console.log('Answer:', answer);
// Check if answer is not null or undefined before splitting
if (answer !== null && answer !== undefined) {
var arr = answer.split('||');
if (window === null) {
g_form.setValue('hardware_options', arr[1], arr[0]);
} else {
addItemsToList('hardware_options', arr[1], arr[0]);
}
} else {
// Handle the case where answer is null or undefined
console.error('Answer is null or undefined.');
}
}
function addItemsToList(listCollector, sysid, displayValue) {
g_form.clearValue('hardware_options');
var bundles = g_form.getValue('u_bundle');
if (bundles == 'mac' || bundles == 'windows' || bundles == 'monitor') {
var varName = listCollector;
var leftBucket = document.getElementById(varName + '_select_0');
var rightBucket = document.getElementById(varName + '_select_1');
var selectedOptionsIDs = [];
rightBucket.options.length = 0;
if (sysid != '') {
var myCIArray = sysid.split(',');
var myDisplayValue = displayValue.split(',');
for (i = 0; i < myCIArray.length; i++) {
var option = document.createElement('option');
option.value = myCIArray[i];
option.text = myDisplayValue[i];
rightBucket.add(option);
}
}
sortSelect(rightBucket);
moveSelectedOptions(selectedOptionsIDs, leftBucket, rightBucket, '--None--');
} else {
g_form.clearValue('hardware_options');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2023 11:49 AM
Hi @nimishpatel ,
Did you check the script include ( findOptions ) method for this options logic, one DEV its returning the values but from PROD there is not data coming. So check that code first.
Share the script include code.
-Thanks,
AshishKMishra
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2023 12:11 PM
Hi @AshishKM ,
Here's the findOptions script include. It seems to be the same from dev and prod.
var findOptions = Class.create();
findOptions.prototype = Object.extendsObject(AbstractAjaxProcessor, {
options: function() {
var bundleSelected = this.getParameter('sysparm_u_bundle');
var hardwareBundle = new GlideRecord('u_hardware_request_option');
if (bundleSelected != 'none') {
hardwareBundle.addQuery('u_bundle', bundleSelected);
hardwareBundle.query();
}
var itemBundleName = [];
var itemSysID = [];
while (hardwareBundle.next()) {
itemBundleName.push(hardwareBundle.u_hardware_name.toString());
itemSysID.push(hardwareBundle.sys_id.toString());
}
return itemBundleName.toString() + '||' + itemSysID.toString();
},
type: 'findOptions'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2023 10:38 AM
did you check on PROD, if there is record in table ( u_hardware_request_option ) based on selected bundle. Assuming the code is exact same on Dev & PROD and Dev is returning the value but PROD doesn't. Check if read ACL (on u_hardware_request_option ) is restricting it.
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2023 11:21 AM
I checked the read ACL on the u_hardware_request_option in PROD and it's the same as DEV. The u_hardware_request_option table is populated in PROD as well.