Variable Sets - make a field open if the user is part of a group
New article articles in ServiceNow Community
·
Feb 15, 2026
·
article
So here is the situation we have and what we are trying to do
I have a Variable Set - User Information
It has the following
Customer Name (reference to active users)
Manager - Customers Manager
Business Reason for Request
What we are trying to do
Manager should be read only, unless the person is part of a group that is allowed to select someone else to approve their request. We have some EA's that have multiple managers that might have to approve.
For the below
We made a group called SN-Multi Approvers, then I added myself to the group for testing.
I found this as a possible solution
Create a Display Business Rule
Navigate to Business Rules in the Application Navigator.
Click New.
Fill in the form:
- Name : A descriptive name (e.g., Set g_scratchpad for Group Membership).
- Table : Select the table where the variable set is used (e.g., sc_req_item, sc_task, or the specific table if used outside the catalog).
- Active : Checked.
- Advanced : Checked.
- When to run :
- When : Display
In the Script field, add the following code, replacing 'YOUR_GROUP_NAME' with the actual name of the group:
javascript
(function executeRule(current, previous /\*null when async\*/) { // Check if the current user is a member of the specified group and store the result (true/false) in g\_scratchpad g\_scratchpad.isGroupMember = gs.getUser().isMemberOf('YOUR\_GROUP\_NAME'); })(current, previous);
- Save the Business Rule.
Create a Catalog Client Script
Navigate to Catalog Client Scripts under Service Catalog > Catalog Administration in the Application Navigator.
Click New.
Fill in the form:
- Name : A descriptive name (e.g., Make Variable Read Only if Group Member).
- Applies to : A Variable Set
- Variable Set : Select the relevant variable set.
- UI Type : All (ensures it works in both the standard UI and Service Portal).
- Type : onLoad.
In the Script field, add the following code, replacing 'your_variable_name' with the actual name of the variable you want to make read-only:
javascript
function onLoad() { // Check the value from the g\_scratchpad set by the Business Ruleif (g\_scratchpad.isGroupMember == 'true') { // Make the variable read-only.// Use the 'variables.' prefix for variables within a variable set in the catalog environment g\_form.setReadOnly('your\_variable\_name', true); // If you have multiple variables, you can set them individually:// g\_form.setReadOnly('another\_variable\_name', true); } }
- Save the Catalog Client Script.
Now, when a user who is a member of the specified group loads the form containing the variable set, the variable will be automatically set to read-only.
My Assumption is this was designed to make the Manager field READ Only, so I set that to False and it should make is open for anyone that is in the group
Currently its not working, and wondering if I missed something or if anyone has any ideas
https://www.servicenow.com/community/itsm-forum/variable-sets-make-a-field-open-if-the-user-is-part-of-a-group/m-p/3489507#M554418