how to hide case states for certain assignment groups in CSM.

Supriya KM
Tera Contributor

Hello Everyone,
I have a requirement where I want to hide the state choices for certain assignment groups. I have used Display business rule and onload client script. its working but not in CSM workspace. Can anyone help me so that it can work in workspace as well.

Display BR:
Conditions as Assignment group starts with "3rd party"
Script:

 

 

g_scratchpad.hideStates = [131,132,141]; 

Onload Client script:

function onLoad() {
    //Type appropriate comment here, and begin script below
    if (typeof g_scratchpad.hideStates !== 'undefined' && g_scratchpad.hideStates.length > 0) {
        hideStateOptions(g_scratchpad.hideStates);
    }

}
//function to hide state option
function hideStateOptions(states) {
    var field = g_form.getControl('state'); //get the state field
    //var field = g_form.getValue('state');
    if (field) {
        var options = field.options;

        for (var i = options.length - 1; i >= 0; i--) {
            if (states.includes(parseInt(options[i].value))) {
                    options[i].remove(); //Remove options

            }
        }
    }
}

 

2 REPLIES 2

ho_dxc
Tera Contributor

Hello, have you tried setting the UI Type field in the client script to All? 

ho_dxc_0-1741176310890.png

 

Ankur Bawiskar
Tera Patron
Tera Patron

@Supriya KM 

it should work provided your client script is running for All views.

Ensure Global checkbox is checked

Also try to add alert and see if onchange runs

If my response helped please mark it correct and close the thread so that it benefits future readers.

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