The CreatorCon Call for Content is officially open! Get started here.

Client catalog script stopped working

nimishpatel
Tera Contributor
Here's a catalog client script that I'm having issues with  that's located in a catalog item that suddenly stopped working. I can't figure out what changed. both dev and prod instances are on Vancouver. Please let me know if anyone has any ideas or if you need more specifics.
 
The catalog item has a few variables out of those few two of them are supposed to interact which I think that's where the client catalog script comes in. it's supposed to populate variable 2 based off of what is selected in variable 1. but it just ends up stating answer is null but it's working on my dev instance.
 
Variable 1 is of type Multiple choice: none, windows, mac and monitor.
Variable 2 is of type List collector.
 
In the dev instance it gives me the following XML response:
 

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');
    }
}

 

 

6 REPLIES 6

nimishpatel
Tera Contributor

   

Sandeep Rajput
Tera Patron
Tera Patron

@nimishpatel This could be due to one of the following reasons.

1. Table u_hardware_request_option doesn't have any record on the prod

2. Table u_hardware_request_option has an ACL which is preventing the access to records

3. Table u_hardware_request_option has a query business rule working on it which is filtering the records

4. There is a difference between the source code of client script/script include on dev and prod.

 

Hope this helps.