- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 08-12-2025 08:17 PM
Dynamic Data Binding in ServiceNow UI Builder: Greet Users Dynamically
Hardcoding text like “Hello user” on a UI might be quick, but it’s not helpful — especially in ServiceNow, where context matters and experiences should feel personal. In this tutorial-style article, we’ll turn a static greeting into a dynamic, user-aware message in UI Builder. You’ll learn three clean ways to bind session data to a Styled Text component so your portal or workspace greets each person by name, without resorting to heavy scripting.
What We’re Building
We’ll start from a simple page layout created in a previous session, then:
- Add a Styled Text component for the greeting.
- Bind it to the logged-in user’s data.
- Do it three ways: direct binding, a lightweight script, and a no-code formula.
Method 1: Directly Bind to Session Properties (No Code)
The fastest, cleanest approach is to bind the component to the current session’s user properties.
- Click the bind data icon next to your Styled Text content field.
- Navigate: Page properties > session > user.
- Double-click a property to bind it (for example, fullName).
- Apply to see the result.
You’ll immediately get something like “System Administrator” if you’re logged in as that user. This proves the binding works, but it’s not a “greeting” yet — it’s just the name.
Method 2: Use a Script Expression for Concatenation (Low Code)
If you want “Hello ” and prefer a single expression:
- Open the bind data panel and switch to the Use Script tab.
- Return a concatenated string, for example:
- return “Hello “ + API.context.session.user.fullName;
Click Apply to see “Hello System Administrator.” This is quick and flexible, but we can avoid code entirely with the next option.
Method 3: No-Code Formula with string.concat
UI Builder’s Formula binding lets you compose strings without writing script.
- In the bind data panel, choose Formula.
- Select string.concat and provide two values:
- Value 1: “Hello “ (include a space)
- Value 2: @context.session.user.userName (or fullName)
Apply to see “Hello admin” or “Hello John Doe,” depending on the property you select.
This approach keeps the experience fully no-code and is great for simple, readable concatenations.
Testing Your Greeting
- Use impersonation to validate the greeting for different roles and users. The greeting should reflect the impersonated user’s name or username immediately.
- If the result doesn’t update, ensure the binding pill shows the correct path and that you used double-click to insert properties.
Practical Tips and Gotchas
- Choose the right attribute: fullName feels more personal; userName is predictable in demos.
- Keep spacing in mind: include the trailing space in “Hello “ to avoid “Helloadmin”.
- Prefer no-code first: Formula and direct bind are easier to maintain than scripts.
- Styling is independent: heading level, alignment, and CSS don’t affect binding — configure them as you like.
Conclusion
You don’t need to hardcode greetings — or write heavy scripts — to personalize UI Builder pages. With a few clicks, you can bind session data directly, use a tiny script for quick concatenation, or stay fully no-code with a string formula.