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

Ashutosh Munot1
Kilo Patron
Kilo Patron
Hi, I see you are using Dom manipulation in script. Have to marked isolated script check box in client script? It won't be visible on form if not visible add it to form, check its value. Thanks, Ashutosh

Ashutosh Munot1
Kilo Patron
Kilo Patron
https://community.servicenow.com/community?id=community_question&sys_id=30d7dd8adbe2a7004abd5583ca961981&isInboxReq=true&anchor=answer_47bc9506db66a7007d3e02d5ca96197e&points=%2010%20points!

It was already on form, have checked it to true but it's still not working in Agent Workspace view. It wasn't working before too when it was checked to false.

Hi,

I also see that you are using  var ri = new GlideRecord('sys_choice');

 

please make use of GlideAjax and not Gliderecord.


Thanks,
Ashutosh