ServiceNow UI Pages: Definition, Purpose, and Use Cases






What are UI Pages in ServiceNow? Your Ultimate Guide to Custom Interfaces



The Wild West of Customization: Diving Deep into ServiceNow UI Pages

Ah, ServiceNow! It’s a platform renowned for its out-of-the-box capabilities, making IT service management, HR, customer service, and a whole host of other enterprise processes smoother than a freshly waxed bowling alley. But let’s be real, no platform, no matter how robust, can anticipate every single quirky, custom requirement your business might throw at it. Sometimes, you need to go beyond the standard forms, the pre-built widgets, and the configured lists. You need a blank canvas, a custom corner where you can truly dictate the user experience and interaction.

Enter UI Pages in ServiceNow. If you’ve spent any time developing on the platform, you’ve likely encountered them, or at least heard whispers of their existence. For some, they’re a powerful tool, an indispensable part of their development arsenal. For others, they’re a mysterious, slightly intimidating beast lurking in the shadows of the platform, only to be invoked when all other options have failed. Today, we’re pulling back the curtain, demystifying UI Pages, and showing you why they’re not just a tool, but an art form.

So, buckle up! We’re going to explore what UI Pages are, their intricate components, when to wield their power, when to maybe step back, and how to master them like a seasoned pro. Whether you’re a budding ServiceNow developer or a veteran looking to refresh your knowledge, this guide aims to be your definitive resource.

So, What Exactly IS a UI Page?

Beyond the Form: A Canvas for Creativity

At its core, a ServiceNow UI Page is a custom web page you build directly within the ServiceNow instance. Think of it as a mini web application living inside your ServiceNow environment. Unlike standard forms that are automatically generated based on table definitions and configured through form layouts, UI Pages give you absolute control over the HTML structure, the client-side interactivity, and the server-side logic.

Imagine you need a complex wizard that guides users through a multi-step process, displaying different fields and options based on their selections, and then consolidating all that information into a single record or performing a complex operation. A standard ServiceNow form, even with intricate UI Policies and Client Scripts, might struggle to deliver that seamless, dynamic experience without feeling clunky. This is where a UI Page shines. It offers the flexibility to craft highly specialized interfaces that perfectly match unique business requirements, providing a truly bespoke user experience.

It’s important to understand that UI Pages are an integral part of ServiceNow’s application development capabilities. They bridge the gap between simple record management and complex application interfaces, allowing developers to extend the platform’s reach in powerful ways. They’re often used for internal tools, specialized reporting, or custom integration front-ends, where the out-of-the-box components aren’t quite enough.

The Anatomy of a UI Page: HTML, Jelly, and Scripts, Oh My!

A UI Page isn’t just one thing; it’s a symphony of several distinct but interconnected components working in harmony. To truly master them, you need to understand each part and how they collaborate.

The HTML Component: Your Basic Building Blocks

Every UI Page starts with good old HTML. This is where you define the static structure of your page: headings, paragraphs, divs, input fields, buttons, tables, and so on. You’re essentially sketching out the skeleton of your interface. You can use standard HTML5 elements, and naturally, you can style them with CSS, either inline, through a style block within the page, or by linking to a UI Style Sheet.

However, it’s not just pure HTML. ServiceNow UI Pages often leverage specialized Jelly tags that abstract away common ServiceNow UI elements. For instance, instead of crafting an HTML `form` tag from scratch, you might use ``, which automatically handles things like form submission and includes necessary hidden fields. You’ll also find tags like ``, ``, or `` that render ServiceNow-styled controls, making your custom page look more integrated with the platform’s native UI.

Jelly Script: The Secret Sauce for Server-Side Magic

This is where things get really interesting and unique to ServiceNow. Jelly is an XML-based templating engine that allows you to embed server-side logic directly within your HTML. Think of it like JSP or PHP, but for ServiceNow. With Jelly, you can:

  • Access Server-Side Data: You can query the ServiceNow database using GlideRecord objects and display the results dynamically on your page. For example, you might fetch a list of active users or display details of a specific record.
  • Conditional Rendering: Use Jelly to show or hide parts of your HTML based on server-side conditions. For instance, display an “Edit” button only if the current user has a specific role.
  • Loops: Iterate over lists of data (e.g., GlideRecord results) to generate dynamic tables or lists in your HTML.
  • Include Other Jelly Files: Modularize your code by including common components.

Common Jelly tags include `` to execute server-side JavaScript and assign its result to a variable, `` for conditional rendering, and `` for looping. Mastering Jelly is crucial for creating dynamic, data-driven UI Pages.

Client Script: Bringing Interactivity to Life

Once your HTML and Jelly have rendered the initial page, client-side JavaScript takes over to add interactivity. This is standard web development stuff: you can manipulate the Document Object Model (DOM), respond to user events (clicks, keypresses, changes), perform client-side validation, and make AJAX calls to the server without reloading the entire page.

Within a UI Page’s client script, you’ll find yourself using familiar JavaScript concepts, but also some ServiceNow-specific global objects:

  • GlideAjax: This is your go-to for making asynchronous calls to Script Includes (which act as server-side API endpoints). You’ll use this extensively to fetch data, save data, or trigger server-side processes based on user actions without a full page refresh.
  • `g_form` (sometimes): While not always available in the same context as standard forms, you can often interact with form elements on your UI Page.
  • `gel()`: A handy ServiceNow-specific shorthand for `document.getElementById()`.

Client script makes your UI Page responsive, user-friendly, and capable of complex, real-time interactions.

Processing Script (Server Script): The Brains of the Operation

When a UI Page form is submitted, or when you make an AJAX call via GlideAjax, the server-side logic kicks in. This processing script, which you write in JavaScript, is where the heavy lifting often happens:

  • Data Persistence: Saving new records, updating existing ones using `GlideRecord`.
  • Complex Calculations: Performing intricate business logic that’s too sensitive or resource-intensive for the client-side.
  • Integrations: Calling external systems or consuming data from other services.
  • Security Checks: Revalidating client-side input and enforcing access controls.

This script can receive parameters from the client-side (e.g., form field values) and then act upon them. It can return data back to the client, redirect the user, or display messages. It’s essentially the backend logic that empowers your custom UI.

Why Bother? Real-World Use Cases for UI Pages

With alternatives like Service Portal widgets, standard forms, and even simple reports, why would you ever choose to build a UI Page? The answer lies in specificity, complexity, and a desire for absolute control over the user experience.

Custom Dashboards and Portals

While Service Portal is the modern approach for public-facing or mobile-friendly portals, UI Pages still find a niche for highly specialized, internal-only dashboards or administrative portals. Imagine an IT manager needing a single view to monitor critical system health, trigger automated recovery actions, and review performance metrics – all within a custom layout not easily achievable with standard reports or Performance Analytics widgets. A UI Page can aggregate data from multiple sources, present it in a unique graphical layout, and even embed custom controls for direct interaction with the underlying systems.

For example, a UI Page could display a custom “On-Call Status” dashboard for a specific team, showing who’s on call, their contact info, and a button to quickly escalate an incident to them, all integrated with a third-party paging system via a Script Include.

Specialized Input Forms and Wizards

Sometimes, collecting information isn’t a simple one-and-done form. Think about a multi-step onboarding wizard for new employees that gathers information across several departments, dynamically changing fields based on prior selections, and finally creating multiple records (User, Asset, Access Request) in a coordinated fashion. Or a complex “Order a Custom Server” form that requires intricate calculations, dependency logic, and visual cues that standard forms can’t provide.

UI Pages excel here because they allow you to break down complex processes into digestible steps, providing real-time feedback and guiding the user seamlessly. You have the flexibility to design the flow, the conditional logic, and the final submission process exactly as required.

Tools and Utilities for IT Staff

Admins and developers often need specialized tools that streamline repetitive tasks or provide quick insights. A UI Page can become an invaluable internal utility. Consider a “Mass User Update” tool that allows an admin to select multiple users, change their department, location, or roles in one go, complete with validation and a confirmation screen. Or a “License Usage Monitor” that pulls data from various applications and displays a consolidated, real-time view of license consumption, potentially with actions to revoke or assign licenses directly from the page.

These tools, while not always pretty, are incredibly powerful for internal operations, offering efficiencies that would otherwise require multiple steps or custom scripting behind the scenes.

Integration Front-ends

When integrating ServiceNow with external systems, a UI Page can serve as a custom front-end for that integration. For instance, if you’re integrating with a legacy CRM system, you might create a UI Page that allows users to search for customer data in the CRM and then pull specific fields into a new ServiceNow record, providing a custom UI tailored to that specific external data model and interaction flow.

When to Use Them (And When to Steer Clear!)

Knowing when to use a UI Page is just as important as knowing how to build one. Over-engineering with a UI Page when a simpler solution exists can lead to maintenance headaches and performance issues.

The “Why Yes!” Scenarios

  • Highly Custom UI/UX: When the standard ServiceNow forms, lists, or even Service Portal widgets cannot achieve the exact look, feel, or interaction pattern required. You need pixel-perfect control over the presentation.
  • Complex, Multi-Step Workflows: For guided processes, wizards, or forms that dynamically change based on intricate user input and require a sequential flow that a single form isn’t suited for.
  • Specialized Internal Tools: For administrative utilities, advanced reporting that goes beyond standard PA/Reports, or niche applications used by a specific set of power users where performance and control are paramount.
  • Legacy Integrations: When interacting with older systems that might require a very specific data input/output format or interaction flow that’s best handled through a custom UI.
  • Backend Functionality with a UI: When you have complex server-side processing (e.g., calling multiple APIs, manipulating large datasets) that needs a user interface to trigger or configure.

The “Hold Your Horses!” Scenarios (Alternatives to Consider)

Before jumping into a UI Page, always consider these alternatives:

  • Standard Forms with UI Policies and Client Scripts: For most record-based interactions (creating/updating incidents, changes, tasks), standard forms are the way to go. UI Policies and Client Scripts offer robust capabilities for showing/hiding fields, making them mandatory, validating input, and simple AJAX calls without the complexity of a full UI Page.
  • Service Portal Widgets: For external-facing portals, employee self-service, or modern, responsive user experiences, Service Portal widgets are almost always the preferred choice. They use Angular JS (or React/Vue with custom integrations) and offer a far more maintainable and scalable approach for public-facing UIs. UI Pages are generally for backend/internal use.
  • Flow Designer / Workflow: For automating processes, approvals, and complex task routing, Flow Designer (or legacy Workflow) is the declarative, low-code solution. It handles the “what happens next” without needing a custom UI for the process itself.
  • Reports & Performance Analytics: If your requirement is primarily data visualization and simple drill-downs, leverage the platform’s powerful reporting and PA capabilities. Don’t build a custom chart on a UI Page unless there’s a truly compelling reason.
  • Custom Tables & Applications: If you’re just storing new types of data, simply create a new table and build forms on top of it. Don’t build a UI Page to simulate a form for a new table.
  • Dashboards: For combining various reports, indicators, and existing widgets into a single view, use the standard ServiceNow dashboards.

Performance Considerations: UI Pages can be heavier and potentially slower to load if not optimized, especially with complex Jelly and extensive server-side calls. They also require more developer effort and specialized skills, making them less agile for quick changes.

The Developer’s Journey: Building a UI Page

Creating a UI Page is a structured process. Let’s walk through the general steps:

Step 1: Laying the Foundation (HTML & Jelly)

You’ll start by defining the basic structure. Navigate to System UI > UI Pages and click “New”. Give it a name and an application scope. In the “HTML” field, begin with your static HTML and intersperse it with Jelly tags. Think about what data you need from the server *before* the page loads (e.g., a list of options for a dropdown) and use Jelly’s `` or `` to fetch and display it.

Example snippet in HTML field:


<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:ui="j2ee.ui" xmlns:f="glide.ui.f" >
    <g:evaluate var="jvar_active_users" object="true" >
        var gr = new GlideRecord('sys_user');
        gr.addQuery('active', true);
        gr.query();
        gr; // Return the GlideRecord object
    </g:evaluate>

    <!-- Include a standard ServiceNow form container -->
    <g:ui_form>
        <h2>Custom User List</h2>
        <p>Select an active user from the list below:</p>

        <label for="user_select">Active User:</label>
        <select id="user_select" name="user_select">
            <j:while test="${jvar_active_users.next()}">
                <option value="${jvar_active_users.sys_id}">${jvar_active_users.name}</option>
            </j:while>
        </select>

        <g:ui_button type="button" onclick="displayUserInfo()" >Get Info</g:ui_button>
        <div id="user_info_display"></div>

        <input type="hidden" name="sysparm_name" value="my_custom_page" />
        <input type="hidden" name="sysparm_action" value="process_selection" />
    </g:ui_form>
</j:jelly>
    

Step 2: Adding the Smarts (Client & Server Scripts)

In the “Client Script” field, write your JavaScript to handle user interactions. This might include validation, dynamic updates, and making GlideAjax calls to a Script Include. In the “Processing Script” field, define the server-side logic that executes when the form is submitted or an AJAX call comes in. This is where you’ll use `GlideRecord` to interact with the database, perform calculations, and prepare data to send back to the client.

Example Client Script:


function displayUserInfo() {
    var userId = gel('user_select').value; // gel() is ServiceNow's document.getElementById()
    if (userId) {
        var ga = new GlideAjax('MyUserUtils'); // Call a Script Include named 'MyUserUtils'
        ga.addParam('sysparm_name', 'getUserDetails'); // Method to call in Script Include
        ga.addParam('sysparm_user_id', userId);
        ga.getXMLAnswer(function(response) {
            var userInfo = JSON.parse(response);
            var displayDiv = gel('user_info_display');
            displayDiv.innerHTML = '<p>Name: ' + userInfo.name + '</p>' +
                                   '<p>Email: ' + userInfo.email + '</p>';
        });
    }
}
    

Example Server Script (Processing Script of the UI Page – not a Script Include):


// This script runs if the UI Page form is submitted traditionally,
// or if called via an AJAX sysparm_action.

var action = request.getParameter('sysparm_action');
if (action == 'process_selection') {
    var selectedUserId = request.getParameter('user_select');
    gs.info('User selected: ' + selectedUserId);
    // Perform server-side actions here, e.g., create a task for the selected user
    gs.addInfoMessage('User ' + selectedUserId + ' was processed.');
    // You can also redirect:
    // response.sendRedirect('incident.do');
} else {
    // This part runs on initial page load if no action is specified
    // Often used for default values or initial setup
}
    

Example Script Include (called by GlideAjax):


// Name: MyUserUtils (Client callable checked)
var MyUserUtils = Class.create();
MyUserUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    getUserDetails: function() {
        var userId = this.getParameter('sysparm_user_id');
        var grUser = new GlideRecord('sys_user');
        if (grUser.get(userId)) {
            var userDetails = {
                name: grUser.name.toString(),
                email: grUser.email.toString(),
                // Add more fields as needed
            };
            return JSON.stringify(userDetails);
        }
        return '{}'; // Return empty object if not found
    },
    type: 'MyUserUtils'
});
    

Step 3: Styling and Polish (CSS)

While UI Pages often inherit some default ServiceNow styling, you’ll likely want to apply your own CSS for a polished look. You can embed CSS directly within `