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

ariesmanlangit
Kilo Expert

Hi,


        For that I think you can tweak the ACL of the table and get the details of the user.. You can put this code in the advanced section.



answer = false;



var userDept = gs.getUserID().getRecord().getValue(<field name here>);




if(userDept != 'India' && userDept != 'England')


        answer = true;



        Something like that... Put it in all the default ACL's of the table. If ever the module is still visible, the table will not be visible.



Hope this helps.



Thank you,


a.c.manlangit


ServiceNow Developer - Philippines



Press Like/Helpful if or mark as the correct answer if applicable.


tnx!


I think you missed the main part of the code which I am looking for.   I am able to fetch user department and check if it is India or England but what after that?



Where should I write this code? - Business Rule, Client script, UI Script?



What should I write to hide the module?



Regards,


Srini


You can write it on the ACL's of the table..



First, elevate your role to a security_admin.


you can do this by clicking the padlock icon on Fuji and Below, or clicking your name>> elevate roles in Helsinki.




Then, in the application navigator, go to the Application System Security>Access Control(ACL).


Find the ACL of the table (which used by your module) by the table name and configure ALL the ACL's from read,write, etc.



Remove the roles included in the default ACL and then configure the script provided in that..



for more info, read here:



http://wiki.servicenow.com/index.php?title=Using_Access_Control_Rules#gsc.tab=0


HarshTimes
Tera Guru

HI


I had similar kind of requirement. i had to hide the application menu for a specific location.I wrote a before query business rule to hide that. Similar way you can do for   modules.



current.addQuery("sys_id","!=","0b3d0df0559e2100e29b566e2a52143a");// sysid of the location.



Put some condition on the business rule so that it will not run everytime for everyone.




Regards,


Harsh