- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on
11-21-2024
10:36 AM
- edited on
11-22-2024
11:08 AM
by
Earl Duque
UI Builder 101
The following article accompanies the UI Builder 101 video by Chris Johnson. Below, you will find explanations for concepts and resources mentioned in the video. Please ask any questions in the comments below!
Table of Contents
Introduction
This article is meant to be a companion to the UI Builder 101 video, it will recap most of what is covered in the video for those of us who prefer to read in lieu of watching an hour long video. It can serve as reference, provide links mentioned in the video, and expand on some points provided in the video that we did not go in to detail about. Please feel free to provide us any feedback in the comments below.
If you're looking for more opportunities to learn UI Builder, and further your learning, check out the links below. We always suggest to start with the UI Builder Fundamentals course if you have access to it on Now Learning, and then do the workshops provided in the Next Experience Workshops site. We have content there for all learning levels, so be sure to check it out!
Context
Our Web Ecosystem
Web Components
<now-button>
, along with attributes that the framework uses to drive functionality. These custom elements work seamlessly within the modern browser environment, adhering to web standards while remaining flexible enough to meet ServiceNow’s unique needs.Widgets vs Components
Our Components
Metadata
Metadata Powered UIs
Experiences and Macroponents
sys_ux_page_registry
table and can be found under the Now Experience Framework module in the "All" menu.Key Features of Experiences:
- URL Structure: Each experience is accessed via a unique URL, structured as a child URL of the experience's root URL (located after
/now/
on your instance). - Landing Page: Users are directed to a default landing page when they access the experience URL.
- App Shell UI: Each experience includes an App Shell UI, which consists of common UI elements across all pages within that experience. This "App Chrome" frames where individual pages are rendered and is configured primarily in Core UI and UI Builder.
- Functional Elements: The App Shell is responsible for crucial functionalities, such as loaders, login/logout interfaces, help features, and search configurations.
Example of a Workspace Experience
/agent
URL would typically have:- A default page located at
/home
, often featuring dashboards or analytics. - A list page at
/list
. - A record page at
/record
. - A customizable vertical icon list and tabs or breadcrumbs for navigation.
Parent App Shells
Macroponents
sys_ux_macroponent
table. Although the term might sound complex, it's essential to understand its significance due to its widespread use across various modern experiences. Macroponents serve multiple purposes, including page composition, components, controllers, viewports, modals, and modeless dialogs. You'll encounter the term "Macroponent" throughout various UI Framework tables and fields, particularly in Core UI.Exploring the Macroponent Record
- Layout: Defines the overall structure and rendering rules of the Macroponent. Any changes made to the styles for the “Body” or “Root” element in UI Builder will reflect in this field. The layout model has evolved to support enhanced capabilities, including responsive design.
- Composition: This field houses the components and their configurations. For instance, if you create a page in UI Builder with a heading, a button, and an image component, all these elements and their configurations will reside in the composition field. When you modify the metadata in the Macroponent, such as changing a heading label, the updates will be visible upon refreshing the page.
- Events: Events play a crucial role in the interactivity of your components. For example, a button click event might be mapped to open a modal, and this mapping is reflected in the Macroponent record. Events can become complex, and they often require relay mappings to communicate with the App Shell for actions like opening and closing modals. For more information on Events, check out this community article.
- Data: The data field contains a list of data resources and their configuration values. Data resources, akin to components, have configuration properties and events but do not have a user interface. Instead, they output data based on their configuration. For example, if you configure a "Lookup a single record" data source to retrieve a record from the Task table, a GlideQuery fetches the desired fields. Changes to the configuration of a data resource automatically update the output, allowing for flexible data binding on the page.
Client Scripts
sys_ux_client_script
table. You can view the associated client scripts for a specific Macroponent in the related list at the bottom of the record.UI Builder
Key Features and Benefits
- Continuous Investment: ServiceNow is committed to the ongoing development of UIB and its underlying framework. By moving UIB to the ServiceNow Store, the frequency of releases has significantly increased, allowing for more frequent enhancements and new features.
- Low-Code Environment: UIB is a low-code tool that allows users to customize existing products, like the Service Operations Workspace or Customer Support Workspace. Additionally, users can build entirely custom application UIs, empowering them to create solutions that meet specific business needs.
- User-Friendly Interface: When you open UIB, you're greeted with a comprehensive inventory of editable elements. This includes a list of Experiences and Page Collections, with future updates planned to incorporate other types of editable elements.
- Support Resources: UIB provides a wealth of resources to help users get started, including help content, tutorial videos, and additional documentation. This ensures that users have the support they need to maximize their use of the tool.
Getting Started
Understanding Pages and Variants
Pages:
- Each page within an experience can host one or more variants.
- Similar to Form views in tables, a page has a designated name and URL path, and it may include Required or Optional parameters.
- When a user navigates to a URL associated with an experience, they are directed to a specific page.
Variants:
- The variant represents the actual user interface presented to the user.
- While multiple records facilitate this process behind the scenes, it’s helpful to conceptualize the variant primarily as the Macroponent record.
- Variants can be tailored based on criteria to determine which specific variant will be displayed.
- For example, workspaces often include multiple record page variants targeting distinct tables, such as a different record page for the user table versus the incident table.
- When creating a variant, you establish the criteria and order for display. The most specific variants should have the lowest order value, while the more general ones should have a higher order value.
Parameters in Pages
Required Parameters:
- These parameters are essential for loading a page. If they are not provided, the page will not render and will return a 404 error.
- Taking the standard workspace record page as an example, it requires two parameters: Table and SysId.
- Any number of required parameters can be defined at the page level, and all variants of that page will require these same parameters.
Optional Parameters:
- Optional parameters allow for added functionality without hindering the page’s accessibility.
- The workspace record page, for instance, includes four optional parameters: query, extraParams, views, and selectedTab.
- When navigating between tabs on a record page, the selectedTab parameter changes, allowing users to copy links that maintain their tab state for others.
Parameter Order and Management
- Required parameters are always listed first in the URL, and the order of these parameters is crucial.
- Optional parameters follow the /params/ segment in the URL and are order-agnostic due to their label-value structure.
- If you add or remove any required parameters after creating links, you must update those links to ensure they contain the necessary parameters; otherwise, users will encounter a 404 error.
Page Editor
- Data Resources: Lists all data resources associated with the page.
- Client Scripts: Displays any client-side scripts that are linked to the page.
- Client State Parameters: Shows the parameters that help manage the state of the client interface.
- Config: Here, you can adjust the various settings and properties for the selected component.
- Styles: This tab controls the visual aspects of the layout and CSS for the component.
- Events: In this section, you can configure the events associated with the component.
Styles Tab
- CSS for Components: Customize the appearance of individual components.
- Page Layout CSS: Adjust how the entire page is presented visually.
Layout Management
- Flexbox: Typically used for one-dimensional layouts, Flexbox is user-friendly and facilitates arrangements in either horizontal or vertical directions. By default, blank pages in UI Builder are set to a vertical flexbox layout.
- Grid: A two-dimensional layout system that is particularly useful for handling variable datasets. For example, if you’re querying the incident table for records assigned to a user, the data volume can fluctuate greatly.
Events
- Types of Events: Events can range from straightforward actions, such as a user clicking a button, to more complex triggers that fire when data is loaded successfully or fails to load. Not all components will have events associated with them, and some may have multiple events defined.
- Default Behavior: By default, events do not perform any action until they are connected to an event handler. This connection is referred to as event mapping.
servicenow.com
when clicked, you would:- Identify the Button Clicked event.
- Bind this event to the “Link to Destination” event handler.
- Page Navigation: Transitioning the user to a different page.
- Displaying Modals or Popovers: Triggering pop-up windows for additional information.
- Client Scripts: Running client-side scripts based on user actions.
- Changing or Setting Client State Parameters: Updating parameters to reflect changes in the UI.
- Loading Animations: Indicating that data is being processed or loaded.
macroponent_ready
and macroponent_property_changed
. These events are triggered at various points in the lifecycle of a page or component and can be particularly useful for managing state and transitions.Data & Data Resources
- Definition: Data Resources are integral components within UI Builder that provide a means to access and manipulate data. They are akin to other components, as they are added to the macroponent using JSON, have configurable options, support events, and are designed for reuse.
- Data Resources can:
- Query Data: Retrieve information from a ServiceNow instance using Glide queries or custom GraphQL queries.
- Transform Data: Alter the format of data to suit specific requirements.
- Read and Write: Both read data from and write data to a ServiceNow instance.
- User name
- Roles
- Local timezone
- Preferences
- Role of Controllers:
- Think of a Controller as a container or folder that encapsulates the data, business logic, and state information required to manage a complex page or specific use case within a page.
- Controllers can include any number of Data Resources, Client Scripts, and Client State parameters, which helps simplify the data management process.
- User Experience Enhancement:
- When the standard Workspace record page transitioned to this Controller paradigm, the number of visible items in the data panel was drastically reduced from over 20 to just 1. This consolidation helps users navigate and configure their pages more effectively.
- Each Record Page Controller offers an output API that supplies the necessary data to all components on that page.
- Backwards Compatibility: ServiceNow-built Controllers follow a defined API contract, ensuring backwards compatibility. The internal workings of Controllers are concealed from users, allowing authors to update and enhance the Controller without affecting the user experience.
Data Binding
- Definition: Data binding is the process of connecting a component to a data source. It allows components to pull in data from various origins as long as the data is formatted correctly for the component.
- Sample Data: When a component is added to a page, it initially comes with sample data to illustrate how it functions and what it looks like. For instance, the heading component may default to the label: "We make work, work better for people with modern digital workflows." This can be customized to any text that fits your needs.
- Personalization Example: When a user logs into the instance and sees a greeting such as "Hi, Chris," the heading component retrieves the user's first name from the session data and concatenates it with a greeting string. This creates a personalized experience, as each user sees their name reflected in the same component.
- Versatility: Any configuration property of a component or data resource within UI Builder can be bound to data. This includes various data types such as strings, booleans, choices, references, arrays, and complex objects. Beyond components, event mappings, scripts, and client state parameters can also leverage data binding.
- Data Binding Syntax: Data binding employs a "dot walk" syntax that acts as an address for a specific part of the data output. For example, the address for the short description in the Record Controller might look like:
@Data.record.form.header.primaryItem.displayValue
- Visual Data Navigation: UI Builder provides a data UI that allows developers to visually navigate the output. This feature enables users to drag and drop "data pills" for easy data binding without needing to type long addresses manually.
- Functions: The data UI supports functions like Concatenate, which can help reduce the need for scripting in many cases, simplifying the development process.
- Hover over the Configuration Property. This action reveals the option to switch to data binding.
- Click the Database Icon. This initiates the data binding process, allowing you to connect to the desired data source.
Upgrades, Presets & Controllers
- Automatic Upgrades: One of the primary advantages of using ServiceNow components is that you receive automatic upgrades and improvements. You always use the latest version of UI Builder components, such as buttons, forms, lists, headings, and over 150 others, without needing to make any changes.
- API Contracts: ServiceNow ensures that component APIs are supported through an API contract, meaning the functionality remains stable even after upgrades. Components that come from plugins or store apps may update more frequently, but the principle of automatic upgrades applies to custom components as well. Any changes made to custom components will reflect across all pages utilizing them, so it's crucial to be aware of how changes to the component API might impact existing pages.
- Similar to Components: Controllers, much like components, maintain an API contract, ensuring that changes do not disrupt the pages that depend on them. Any alterations made to a controller automatically apply to every page that uses that controller.
- Encapsulation: Controllers encapsulate data fetching, business logic, and state, providing a structured approach to manage complex workflows and applications.
- Presets were introduced in the Tokyo release to encapsulate configuration in an upgrade-friendly manner and speed up page building. They allow for the automatic configuration of components and data by connecting components to a controller.
- Use Case Example: A common use case involves the heading component displaying the primary field (often the short description). When you select the heading component and choose the "Record title" preset, the preset automatically sets all necessary configuration properties to bind the heading to the primary field data.
- Form Controller Integration: If no controllers are present on the page, the preset will add a Form Controller to facilitate querying the short description from the database.
- Custom URL Parameters: The Form Controller defaults to use required URL parameters to get its Table and SysId. Users are notified if this action will modify the URL structure for the page. If desired, users can choose to configure this manually by hardcoding the Table and SysId.
- Override Functionality: If a user wants to modify a specific configuration (e.g., changing the heading text style), they can do so by overriding just that property instead of removing the preset entirely.
- Maintaining Upgrades: By overriding a single configuration property, users retain the advantages of the preset's upgrades for other properties while maintaining their custom changes. The preset continues to control all other properties, ensuring that users continue to receive updates and enhancements without losing their specific configurations.
- Storage of Overrides: Overrides are stored within the macroponent record being edited, meaning users can only override settings for pages they have edit access to.
Conclusion
We hope this video and article provided an in-depth look at ServiceNow's approach to modernizing its web platform, including the use of UI Builder, the Next Experience UI framework, and the importance of metadata in creating low-code, flexible applications. Chris Johnson, the director of design on the web platform team, shared valuable insights into the evolution of ServiceNow's UI, the benefits of web components, and the significance of controllers and presets in ensuring upgradability and efficiency.
We hope this video has answered many of your questions and provided a clear understanding of the tools and capabilities available to you. If you have any further questions or topics you'd like us to explore in future videos, please post them in the comments section below. Your feedback is invaluable in helping us improve and deliver content that meets your needs.
Check out the Next Experience Center of Excellence for more resources
- 8,804 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Great content! Thank you for wrapping it up on one place 🙂
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
How do we move dashboards built in UI Builder from one environment to another?
Update sets? XML? Is there an easy way to capture everything built in a page/variant and move it all at once?
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Great content. Thank you for providing a readable content for some of us who find watching a video exhausting
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Awesome understandable content.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Thank you so much. A succint and a very well thought out overview of a complex topic.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
"Thank you for this detailed and informative content! I have a question: Can we use custom-developed components created with the Now Experience Framework in a Portal App Shell page? Specifically, are they reusable across both Workspaces and Portal App Shell experiences? Looking forward to your insights!"
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
In response to the question from @sabra_gr about whether custom components can work in the Next Experience Portal App Shell (not, Angular Portals, those are different) the answer is in almost all cases that yes, the components will work anywhere.
Now, here is the caveat. If a custom component is designed to work with a specific piece of data or event that is provided by ONLY a specific App Shell, that component wouldn't work in another context that lacks the data or events. But ServiceNow doesn't ship components that work in this manner, and I would argue that this is a best practice. The data and events that are provided by the various app shells in UIB are quite similar, with most of the differences related to how you navigate inside of them (e.g. the tabs app shell has events around tabs whereas the breadcrumb doesn't because it doesn't have tabs).
You can read more about the different app shells here.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Good wealth of knowledge in one article, thank you!
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
@pkchrisjohnson Thank you for your answer!
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Great content!👨💻
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Very informative, thanks for such a great video, easy to follow and also fun to watch !
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Amazing Content!
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
This video should be a template for conveying information on complex topics. Chris, you explained this material in a way that, as a developer, completely made sense to me. You followed up with some relatable examples. You also anticipated many follow-up questions someone new to UI Builder would surely have when explaining a new concept. Bravo