[Article] How to Hide a Section in ServiceNow Using Client Script: A Beginner-Friendly Guide
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
How to Hide a Section in ServiceNow Using Client Script: A Beginner-Friendly Guide
Making ServiceNow forms cleaner isn’t just about looks. It can make your team’s work faster and much less confusing. Today, I’ll walk you through the process for hiding a section in ServiceNow using Client Script. Whether you’re starting with ServiceNow or sharpening your customization skills, this guide gives you what you need: practical advice, common pitfalls, and real best practices—all step by step.
Prefer to watch? Here's a full video tutorial:
ServiceNow doesn’t always need to show every field or section on a form. Sometimes, you want to reduce clutter, hide information that’s not relevant, or create a more focused user experience. Client Scripts help you do that—and much more—with a few simple tweaks in JavaScript. I’ve learned that understanding how these scripts work is the first step to smarter, cleaner, and more efficient ServiceNow forms.
What Is a Client Script in ServiceNow?
Client Scripts in ServiceNow run right in your browser while you use a form. They can change how a form
responds based on what you do, adjust form fields, make fields read-only, or even hide entire sections.
Key Components of a Client Script
- Script Name: I always pick a name that matches what the script does, such as “Hide Incident Form Section.”
- Table Association: Each script is tied to a specific table, like the “incident” table. This tells ServiceNow where to run the script.
- Event Type: This decides when the script runs. Common events include onLoad (when the form loads), onChange (when a value changes), and onSubmit (when saving). For hiding sections, you’ll likely use onLoad so the section hides as soon as the form opens.
- UI Type: The script can target desktop, mobile, or both. For most users, “desktop” (UI16) is typical.
Here’s a quick summary:
Component Purpose
Script Name | Describes what the script does |
Table Name | Points to the specific ServiceNow table |
Event Type | Sets when the script should execute |
UI Type | Chooses if the script runs on Desktop, Mobile, or both |
Getting Started: Setting Up Your Client Script
Steps to Start
- Open the form you want to customize (for this example, the Incident form).
- Go to the related list for Client Scripts, usually at the bottom of the form setup screen.
- Click “New” to create a new script.
- Enter a descriptive name like “Hide Notes Section on Incident Form.”
- Select the relevant table (e.g., incident).
Pick the Best Event and UI Type
- Set the Type to onLoad so your changes apply when the form loads.
- For UI Type, choose “Desktop” if you’re working in the standard web interface (UI16). These settings make sure the script runs where you want.
Testing Your Client Script on the Incident Form
Here’s how to test your work:
- Open the Incident form in your ServiceNow instance.
- Make sure your script is active and of type onLoad.
- Reload the form page.
If the script works, you’ll notice the targeted section is hidden when the form loads. If it didn’t work, double-check the script settings, the table name, and the section name or identification.
Best Practices for Using Client Scripts in ServiceNow
Using client scripts wisely makes your forms cleaner and easier to use. Here’s what I keep in mind for every script:
Benefits of Hiding Sections
- Streamlined Forms: Fewer distractions help users work faster.
- Clearer Data Entry: Users focus only on what matters, cutting down on errors.
- Custom Experience: Show each user only the fields and information they need.
Tips for Writing Client Scripts
- Test in Development First: Always try scripts in a safe environment before going live.
- Use Descriptive Names: Name scripts for exactly what they do.
- Document as You Go: Add a short comment about what the script accomplishes.
- Handle Errors: Think about what happens if a section name is wrong or missing.
- Consider the Audience: Will this help or confuse new users?
Common Pitfalls
- Forgetting a Page Reload: If your event is onLoad, a reload is required to start the script.
- Mismatched Section Names: Double-check the section name or ID.
- Wrong UI Type: Scripts for “desktop” won’t run in mobile and vice versa.
- Leaving Demo Alerts or Testing Code: Clean up before deploying.
Best Practices Common Pitfalls
Always test before deploying | Typos in section names |
Use clear, descriptive names | Forgetting to set UI type |
Document script purpose | Wrong array index |
Add error handling | Leaving test code in live use |
More Ways to Learn: Resources and Next Steps
ServiceNow customization offers lots of opportunities to build your skills. If you want to dive deeper, consider hands-on training, instructor-led virtual labs, or community events. Resources like the ServiceNow Community and live training at iLearnTech can make a big difference.
Found this guide helpful?
If you’re in the ServiceNow community and want more tutorials, subscribe or join as a member on TechTalk with Bill’s channel. Add your ServiceNow challenges or tutorial requests in the comments. What’s the hardest part of form customization for you? Share below—I want to help the community with guides that answer your real questions!
Key Takeaway: Hiding a section in ServiceNow with a client script is simple when you plan, test, and name things clearly.
If you want to keep leveling up your ServiceNow skills, subscribe, join, or comment below with what you’d like to see next. Let’s help each other build better ServiceNow experiences!