Hide a module based on user department or any other field

Geeky
Kilo Guru

Hi,

I have a requirement to hide a specific module based on one of the field on the user table. Initially I thought to create a role, assign that role to the module and add all the filtered users to the role but this is not a perfect solution since the field on the user form can be updated at any time.

For e.g. : I want to hide 'My Asset' module if the users department is either 'India' or 'England'.

Does anybody have any ideas to meet this requirement?

Regards,

Srini

1 ACCEPTED SOLUTION

Hi


Sorry, Mistake in last reply. In addquery it will be the sysid of the module that you want to hide.Please put sysid of module that you want to hide in addQuery




current.addQuery('sys_id', '!=', 'ec84ca0cdbfa620075d372ffbf9619cc'); //sysid of the module that you want to hide.


var qc1 = current.addQuery('title', '!=', 'My Profile');// this is not required.


View solution in original post

11 REPLIES 11

Hi Harsh,



I have written something similar to that but it is not working. Can you check the code and let me know if I am missing something?



hide.png



(function executeRule(current, previous /*null when async*/) {


     


  var u = gs.getUserID();



  var gr = new GlideRecord('sys_user');


    gr.addQuery('sys_id',u);


  gr.query();


  if(gr.next())


  {


  gs.addInfoMessage(gr.title);


        if (gr.title != 'ServiceNow')


  {


  var qc = current.addQuery('sys_id', '!=', 'ec84ca0cdbfa620075d372ffbf9619cc');  


  var qc1 = current.addQuery('title', '!=', 'My Profile');


  }


  }



})(current, previous);


Hi


Sorry, Mistake in last reply. In addquery it will be the sysid of the module that you want to hide.Please put sysid of module that you want to hide in addQuery




current.addQuery('sys_id', '!=', 'ec84ca0cdbfa620075d372ffbf9619cc'); //sysid of the module that you want to hide.


var qc1 = current.addQuery('title', '!=', 'My Profile');// this is not required.


It worked on regular servicenow instance but not on ESS portal. Where to include this script for ESS portal modules?


Please send me the screenshot of you ESS Page.


Hi, 

 

post kingston, this doesnt work as expected. do you have any other idea for this ? 

 

Thanks 

Girish Deshpande