Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to hide an incident state (canceled) from the list view?

Jesus Nava
Tera Guru

Hello experts, please I need your help, how can I hide the choice canceled from the "state" dropdown from the list view?

find_real_file.png

Thank you

1 ACCEPTED SOLUTION

Community Alums
Not applicable

@Jesus Nava same script i have used & tested , able to edit on list view and change any state except cancel, working code on my PDI

function onCellEdit(sysIDs, table, oldValues, newValue, callback) {
    var saveAndClose = true;
    if (newValue == 😎 {
        alert("You cannot change the state to Closed from the list view.");
        saveAndClose = false;
    }
    callback(saveAndClose);
}

View solution in original post

11 REPLIES 11

okay, then you can write onCellEdit client script to achieve that.

Community Alums
Not applicable
Hi, You can use below client script, function onCellEdit(sysIDs, table, oldValues, newValue, callback) { var saveAndClose = true; if (newValue == "take value of cancel") { alert("You cannot change the state to Closed from the list view."); saveAndClose = false; } callback(saveAndClose); } Hope this will help.

Hello Abhay, I have this:

Field Name: cancel

function onCellEdit(sysIDs, table, oldValues, newValue, callback) {
  var saveAndClose = true;
 //Type appropriate comment here, and begin script below
 if(newValue == '8'){
    alert("You cannot change the status from the list view"),
    saveAndClose = false;}
 }
 callback(saveAndClose); 

 

but now from the list view that field is uneditable, am I doing something wrong?

Hi @Jesus Nava 

May I ask why are you taking field name as "Cancel"?

Regards,

Palak

Sorry my bad, the field name I selected is State, not Cancel