Context Menu

monu1
Giga Contributor

What condition shall I put on VIEW context menu so that admin can see the view but itil cannot.

Actually admin has itil role by default.

Please do answer the condition .

Thank you

1 ACCEPTED SOLUTION

amlanpal
Kilo Sage

Hi Manisha,



The condition should be as of below. You just need to add the bold portion.


ListProperties.canChangeView() && gs.hasRightsTo('ui/context_menu.view/read', null) && gs.hasRole("admin")



I hope this helps. Please mark correct/helpful based on impact


View solution in original post

8 REPLIES 8

amlanpal
Kilo Sage

Hi Manisha,



The condition should be as of below. You just need to add the bold portion.


ListProperties.canChangeView() && gs.hasRightsTo('ui/context_menu.view/read', null) && gs.hasRole("admin")



I hope this helps. Please mark correct/helpful based on impact


Hi monu,



If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.


If you are viewing this from the community inbox you will not see the correct answer button.   If so, please review   How to Mark Answers Correct From Inbox View


lSurya 24
Giga Guru

Hello Manisha,



Try the UI Script.



Create a new UI Script, and check the Global checkbox.



Use the script as following:



T


To disable the context menu for roles except admin:




  1. addLoadEvent(hideContextMenu);    
  2. function hideContextMenu(){    
  3.   try{    
  4.   if(!g_user.hasRole("admin")){  
  5.   this.contextShow = function(){return false;}  
  6.   }    
  7.   }  
  8.   catch(e){    
  9.   alert(e);    
  10.   }    
  11. }    





Thanks,


Surya Amara



PS: Hit like, Helpful or Correct depending on the impact of the response


Dave Smith1
ServiceNow Employee
ServiceNow Employee

Are you simply after making a view (a list structure) available to specific users? (i.e.: users with a specific role?)



If so, System UI > Views allows you to define the roles that are able to see (and therefore use) a specific view.