Script not working in Agent Workspace

SN Rookie
Giga Expert

We have some scripts which removes Category values based on the view. The below category is working fine in Incident 'default view' , however it doesn't work in Agent Workspace. I have changed the UI type to All but it still doesn't work. Is it true that GlideRecord is not supported in Agent workspace at all?

Can someone help or convert this into GlideAjax to get it working if possible?

function onLoad() {
    var sd = false;

    //Type appropriate comment here, and begin script below
    var objView = document.getElementById('sysparm_view');
    var strView = objView.getAttribute('value');
    var category = g_form.getValue('category');
    var ri = new GlideRecord('sys_choice');
    var asgrp = g_form.getValue('assignment_group');
    if (asgrp != '070a28ca0a0aa02e01ac6d7bd6ddab6b' && asgrp != '6dfbd5f00a0aa02e01f7eebe4998eb13' && asgrp != '070a26580a0aa02e009bb544858499a7') {
        sd = false;
    } else {
        sd = true;
    }

    // hide GBO OPTIONS FOR CATEGORY
    if (strView != 'GBO' && category.indexOf('GBO -') < 0 && !sd) {

        ri.addQuery('element', 'category');
        ri.addQuery('label', 'LIKE', 'GBO -');
        ri.query();

        while (ri.next()) {
            g_form.removeOption('category', ri.value, ri.label);
        }
    } else if (sd) {
        return;
    } else {
        // hide other category for GBO SRM
        //var ri = new GlideRecord('sys_choice');
        ri.addQuery('element', 'category');
        ri.addQuery('label', 'DOES NOT CONTAIN', 'GBO -');
        ri.query();
        while (ri.next()) {
            g_form.removeOption('category', ri.value, ri.label);
        }
    }

}
10 REPLIES 10

Matt102
Giga Guru

"Can someone help or convert this into GlideAjax to get it working if possible?"

Help, possibly.

I had a similar issue. It was due to trying to do

g_form.getValue('field in default view but not workspace view');

i.e. if you are using a g_form.getValue to get a value that dunt exist in that form view - you wont get the value!

I dont have a working glideajex to hand, however, _perhaps_ more performant, you could try setting a Display Business Rule and in the Script set a g_scratchpad variable, for the value you need client side

#justathought