How to Make Catalog Item Variable Field Visible Only to Selected Users?

jlouie
Kilo Explorer

Hello,

 

Does anyone know how to restrict the visibility to only selected users (or a group) for a Service Catalog item variable field?

 

My catalog item contains 2 variables:   1 that asks a question and a second that I'd like to use to store the XML document results from a call to a SOAP external Web service function.   I would like the second variable to be only visible on the form to certain users (our DBA group members) since this XML logging info should not be seen by the requester or anyone else outside the DBA group.

 

In my test, after the catalog item request has completed executing, the XML results (activity.output) do display in the second variable on the form.   But I want to hide this second variable field on the form from anyone other than the DBA group members.

 

I am new to ServiceNow and scripting, so any helpful pointers would be much appreciated.   Thank you.


9 REPLIES 9

robpickering
ServiceNow Employee
ServiceNow Employee

Joyce, I have a similar question over at:


Hiding Catalog Item Variables based on Group Membership



Where you able to actually hide your variable based on Group Membership?   From what I can tell you cannot do this using out-of-box UI Policies or Client Scripts, as you don't have access to the user's groups when they're interfacing with the catalog item.   You can do it for roles, that's straightforward, but not for Group Memberships.



It's strange to me because there is OOB functionality to show/hide Categories, Catalog Items and Variable Sets using Group Memberships (via the "Visible to groups" related list), but that related list doesn't exist on individual Variables on a Catalog Item.



The only way I've found I can do this easily (and it's not easy in my case) is to create an entirely new Variable Set, put only that variable in it, and then use the UI Policy to show/hide that entire Variable Set.   Certainly not ideal, as the variable I want to hide is already part of a Variable Set.



Just hoping you were able to get this working...


What has become common for us in these situations is having a hidden variable that is populated by an onload script.   Onload we would do an AJAX call to see if the user is a member of this group, and populate it with YES/NO.   Then a normal UI policy based off this hidden variable to show/hide the second variable.


Chris, this may be an ignorant question, but how do you do a UI Policy on a Catalog Variable that is part of a Variable Set?   When I go into the UI Policy I'm only presented with two options in the "Applies to" drop-down:   "A Catalog Item" and "A Variable Set".   How do I perform the UI Policy on a single variable within a set?


The UI Policy would need to be within the Variable Set itself, and not on the item.


Chris, that's where I'm doing it, you do not get the option to make it against a variable, only the set itself.