Best way to display a form field to specific logged in users?

richelle_pivec
Mega Guru

I have a choice list field that I am adding to our RITM form (called BRM Assist). The field needs to only display when the Logged in User is one of four specific users or an Admin. The users are all in the "BRM" Assignment Group, but the RITM won't necessarily be assigned to that group. (I'll also be adding a similar field to the Change, Problem and Incident forms.) What would be the best way to display a field on a form for only a specific group of users to use? It is fine for the field to be available in the List View and to be Reported On. The ask is that the forms don't get cluttered up with a field that would confusing to all but a handful of people who need to use it.

thanks,

Richelle

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

Hi Richelle,



I would add a role to that group and then use a client script to display/hide that field based on whether the current logged in user has that role.



Client Scripts - ServiceNow Wiki


GlideUser (g user) - ServiceNow Wiki  


View solution in original post

2 REPLIES 2

Chuck Tomasi
Tera Patron

Hi Richelle,



I would add a role to that group and then use a client script to display/hide that field based on whether the current logged in user has that role.



Client Scripts - ServiceNow Wiki


GlideUser (g user) - ServiceNow Wiki  


Thank you for the great idea. I made a new role called "BRM" and added it to their group.



Then I made this "On Load" client script on the RITM form:



function onLoad() {


    //Type appropriate comment here, and begin script below


      var isBRM = g_user.hasRole('BRM');


              if(isBRM == true){


              //unhide it


              g_form.setVisible('u_brm_assist', true);                    


              }


              else {


              // hide it


              g_form.setVisible('u_brm_assist', false);


              }


}


   



Worked like a charm.


Thanks again,


Richelle