how to hide choice list field value in list view?

daggupati
Tera Contributor

Hi,

    I have a issue, in incident i have field call state, in that i have values like open, in progress, resolved and closed. so, for itil users i want to hide closed option in both list and form view?

7 REPLIES 7

The SN Nerd
Giga Sage
Giga Sage

For the list view, in terms of selection, it is all or nothing.



  • Prevent users from editing the state field via a list_edit ACL
  • Disable list editing for the list
  • Create a business rule to prevent users from setting ticket to closed, do via UI action


For the form:




ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

Mike Allen
Mega Sage

The form part is easy.   onLoad Client Script that says



if(g_user.hasRole('itil')){


        g_form.removeOption('state', 6); // or whatever your closed value is


}



The easiest way to do it in a list is to put a business rule that says



Condition: gs.hasRoleExactly('itil') && current.state.changesTo(6)



current.setAbortAction(true);
gs.addErrorMessage('itil users cannot close tickets.');


You can also check out List Client Scripts: sys_ui_list_script_client



They have been deprecated, it seems, but you can still use them.



There are also list business rules: sys_ui_list_script_server


Is there any documentation or additional info on these scripts availabgle somewhere?