Troubleshooting: Hiding Variable Sets in ServiceNow Mobile View
- nathanlee142
- Mar 21
- 3 min read
Updated: Mar 26

Are you a ServiceNow administrator or developer struggling to hide variable sets in the mobile view of your catalog items? You're not alone! Many ServiceNow users encounter this challenge where client-side scripts that work perfectly for individual variables seem to fall short when applied to variable sets in the mobile interface. This article will guide you through understanding why this happens and provide verified solutions to effectively hide your variable sets on mobile devices.
Understanding the Challenge of Hiding Variable Sets in Mobile
The ServiceNow mobile experience, while designed for efficiency, sometimes handles UI elements differently than the standard web interface. When attempting to hide a variable set using client-side scripting, you might find that the script executes without errors, but the variable set remains visible. This often leads to confusion, especially when the same logic works flawlessly for individual variables within the same catalog item. The core issue typically lies in how the script is being applied and the specific context of variable sets within the mobile view.
Proven Solutions to Effectively Hide Variable Sets
Based on community experiences and accepted solutions, here's a breakdown of how to successfully hide variable sets in the ServiceNow mobile view:
1. Leverage Client Scripts or UI Policies Correctly:
Both Client Scripts and UI Policies can be used to control the visibility of elements on a ServiceNow form. When dealing with variable sets in the mobile view, the key is to ensure they are configured to apply to the Catalog Item and not directly to the Variable Set itself.
Step-by-Step Guide:
Navigate to your Client Script or UI Policy: Open the relevant Client Script or UI Policy you are using to hide the variable set.
Verify the "Applies to" setting: Ensure that the "Applies to" field is set to Catalog Item. This is a crucial step. Selecting the Variable Set name here will likely result in the script not working as expected in the mobile view.
Specify the Catalog Item: Once "Catalog Item" is selected, a field to choose the specific catalog item will appear. Select the name of the catalog item where you want to hide the variable set.
Use the appropriate g_form method: Within your Client Script or UI Policy's script section, use either g_form.setDisplay() or g_form.setVisible() to hide the variable set. The syntax should be:
g_form.setDisplay('YOUR_VARIABLE_SET_NAME', false);
or
g_form.setVisible('YOUR_VARIABLE_SET_NAME', false);
Replace 'YOUR_VARIABLE_SET_NAME' with the actual name of your variable set.
Example Use Case: Imagine you have a catalog item for ordering a new laptop. You have a variable set containing detailed policy information that is only relevant for desktop users and not mobile users. By following the steps above, you can create a Client Script that checks if the user is accessing the catalog item from a mobile device and then hides the "Policy Information" variable set accordingly.
2. Consider Hiding Individual Variables as a Test:
If you're still facing issues, a helpful troubleshooting step is to try hiding an individual variable within the problematic variable set. This can help you determine if the issue lies with the overall variable set or something else. Use the same g_form.setDisplay() or g_form.setVisible() method, but target a specific variable name instead of the variable set name.
3. Handling Containers within Variable Sets:
In some cases, variable sets might contain containers. ServiceNow might treat these containers as separate entities within the mobile view. If you have containers within your variable set and the above solutions aren't working, you might need to add separate lines of code in your Client Script or UI Policy to specifically handle the visibility of these containers as well.
Conclusion: Taking the Right Steps to Hide Variable Sets
Hiding variable sets in the ServiceNow mobile view requires a slightly different approach than hiding individual variables. The key takeaway is to ensure your Client Scripts or UI Policies are applied at the Catalog Item level and correctly target the name of the variable set using the g_form.setDisplay() or g_form.setVisible() methods. By carefully verifying your configuration and considering the presence of containers, you can effectively control the visibility of your variable sets and provide a cleaner, more user-friendly mobile experience for your ServiceNow users. Remember to test your changes thoroughly on actual mobile devices to ensure the desired outcome.