Catalog Item ref_ac_columns broken after using g_list in client script

Jacob5
Tera Contributor

Sadly I've found that on catalog items, on a reference variable; on reference attributes; ref_ac_columns breaks after calling the reference variable via g_list.get();

I have a suspicion that it's because I'm using ; to insert multiple fields on ref_ac_columns e.g ref_ac_columns=name;approver;code, and for some reason when using g_list(), it gets confused with ; and now I can only search the reference field with the first declared variable e.g name.

is there anyway to get around this? This is a major pain point as I have to change the reference query with client script after a change of another field, and can only achieve this in client script.

 

atm my reference attributes is:ref_auto_completer=AJAXTableCompleter,ref_ac_columns_search=true,ref_ac_columns=manager;name;code

 

and client script affecting this is:

function onChange(control, oldValue, newValue, isLoading) {
    /*if (isLoading || newValue == '') {
        return;
    }*/

    if (!isLoading) {
        g_form.clearValue('approver');
        g_form.clearValue('cost_centre');
    }

    var collectorName = 'cost_centre';

    var type = g_form.getValue('approving_district');
    var query = '';

    query = '^u_district=' + type;

    var queryFin = '^u_active=true' + query;

    try { // Service Portal
        var myListCollector = g_list.get(collectorName);
		myListCollector.reset();
        myListCollector.setQuery(queryFin);
    } catch (e) {
        g_form.setDisplay(collectorName, false);
        setCollectorFilter();
    }

    function setCollectorFilter() {
        if (typeof(window[collectorName + 'g_filter']) == 'undefined') {
            setTimeout(setCollectorFilter, 100);
            return;
        }
        window[collectorName + 'g_filter'].setQuery(queryFin);
        window[collectorName + 'acRequest'](null);
        g_form.setDisplay(collectorName, true);
    }

}
1 ACCEPTED SOLUTION

Hi,

why not use advanced ref qualifier to filter the list collector instead of using above script?

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

5 REPLIES 5

Jacob5
Tera Contributor

On cost center, depending on a previous selection i.e ‘District’, we then need to narrow down the cost centers to the ones that belong to that district. To do this I’m setting the query on an onchange client script, on the district variable.

 

But once calling that cost center reference variable via g_list, everything after the first ref_ac_column does not seem to work anymore.