How to hide a particular choice (like "Closed") from the list view choice dropdown in ServiceNow?

sndevastik
Tera Contributor

I have a requirement to hide a specific choice (e.g., "Closed") from the list view choice dropdown in the Incident table, but only for ITIL users. I’m aware we can restrict updates using onCellEdit client scripts or before business rules, but here the need is to actually hide the option, not just restrict it. Is there a way to achieve this?

2 REPLIES 2

Community Alums
Not applicable

Hello @sndevastik,

 

There’s an important distinction here: restricting updates vs. actually hiding a choice from a dropdown. 

  • If you just want to prevent users from saving a certain choiceonCellEdit client script or a business rule works fine (like you mentioned). 
  • If you want to hide the choice entirely from the dropdown for specific roles (like ITIL users) >you need to dynamically filter the choice list using a Client Script (onChange / onLoad) or a UI Policy with g_form.removeOption(). This will remove the choice from the UI so users never even see it. 

Example script using onCellEdit to remove the choice instead of just blocking it: 

function onCellEdit(sysIDs, table, oldValues, newValue, callback) { 
   var saveAndClose = true; 
 
   // Hide "Closed" choice for ITIL users 
   if (g_user.hasRole('itil')) { 
       // Remove the "Closed" option from the incident state dropdown 
       g_form.removeOption('incident_state', '7'); // 7 = Closed (check your sys_choice value) 
   } 
 
      if ((newValue == '7') && !g_user.hasRole('admin')) { 
       alert('Only admin can select this choice'); 
       saveAndClose = false; 
   } 
 
   callback(saveAndClose); 
} 
 

Docs you may find useful: 

 

Thanks & Regards,  
Muhammad Iftikhar  

If my response helped, please mark it as the accepted solution so others can benefit as well. 

 

Hi  @Community Alums ,

 

 The question is for list view .the g_form methods don't supported in list view .

 

Thanks,
Astik