Hide filters in related list

Abinash
Kilo Contributor

I have default filters defined in my affected ci's related list but i dont want those filters to be visible to my users. How can i achieve that??

find_real_file.png

I want this filter to be hidden. Kindly help me to achieve this

Thanks in advance

1 ACCEPTED SOLUTION

Ok. I don't think there is any OOB method available for hiding that filter. I achieved this by using DOM, Please write a UI Script as mentioned below:



Scenario:



For example on the Change form we have the Problem Related List, so I am hiding the filter on the Problem Related List only present on the Change form for all the Users except the Admins.



Script:



try {


  var loc = window.location.href;


  if((loc.indexOf('sys_target=problem')>0) && loc.indexOf('sysparm_collection=change_request')>0)   //this would only hide for Problem & Change combo


  {


  setTimeout(setMyFilter, 1000);


  function setMyFilter()


  {


  if(!g_user.hasRole('admin'))                                 //This will allow to hide for all except Admins


  {


  document.getElementsByClassName('col-sm-offset-2 col-sm-8 m2m_filter_container')[0].style.display='none';


  }


  }


  }


}


catch (e) {



}



find_real_file.png



Make Sure "Global" checkbox on the UI Script form is marked as True as highlighted above.



Result:



find_real_file.png


Hope this helps.Mark the answer as correct/helpful based on impact.



Regards,


Shloke


Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

View solution in original post

18 REPLIES 18

Heello, plz i ve created a UI script with the same script and i ve changed the sys_target & sysparm_collection following my needs but at the end it doesn't work !!


where the problem can came from ?


Can you post a screenshot of the UI Script form Configured?



Regards,


Shloke


Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hi , 

I need to do the same thing in adding group member by clicking edit button , i wrote suggested ui script but it is no working 

Kindly suggest this line ---     if((loc.indexOf('sys_target=problem')>0) && loc.indexOf('sysparm_collection=change_request')>0)

instead of this i am using if(loc.indexOf('sys_target=sys_user_grmember')>0)

 

script of my:-

try {

 

  var loc = window.location.href;

 

  if(loc.indexOf('sys_target=sys_user_grmember')>0)

 

  {

 

  setTimeout(setMyFilter, 1000);

 

  function setMyFilter()

 

  {

 

  if(!g_user.hasRole('admin'))                                 //This will allow to hide for all except Admins

 

  {

 

  document.getElementsByClassName('col-sm-offset-2 col-sm-8 m2m_filter_container')[0].style.display='none';

 

  }

 

  }

 

  }

 

}

 

catch (e) {

 

 

 

}

 

 

Please kindly suggest ashok

akhil reddy2
Mega Contributor

Hi I don't want ITIL USER to edit this filter it should be read only

can anyone suggestfind_real_file.png