- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2025 03:25 AM
I have a rich text label field. I have to populate the logged in user in this field. Its urgent anybody could help?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2025 03:52 AM
Hello @garimakharb ,
The functionality you're looking for—populating the logged-in user's name in a Rich Text Label—is not directly possible. Rich Text Label variables in Service Catalog don't support scripting or dynamic updates, so you can't inject something like the user's display name into them using setValue() or similar methods.
However, there is a workaround using a Custom type variable with a Service Portal widget. This allows you to display dynamic text, like showing a welcome message with the current user's name.
Here’s how you can do it:
Step 1: Create a custom widget
-
Navigate to Service Portal > Widgets and click "New".
-
Give it a name like “Display User Greeting”.
-
In the HTML Template field, add:
<div>
<p>Welcome, {{data.user_name}}</p>
</div>
4 . In the Server Script field, add:
(function() {
data.user_name = gs.getUserDisplayName();
})();
5. Submit the widget.
Step 2: Add a Macro or Custom variable to your catalog item
-
Open your catalog item or record producer.
-
Under Variables, click New.
-
Set the Type as “Custom”.
-
In the Type Specifications, choose the widget you just created.
-
Fill out the rest of the details as needed and save.
Now when the item loads in the portal, the user should see a greeting message with their name.
This approach was also discussed in another thread by Michael Jones where he shared a similar solution. It matches your use case quite well, so I’d recommend checking that out too for more clarity.
Let me know if this helps.......
🔹 Please mark ✅ Correct if this solves your query, and 👍 Helpful if you found the response valuable.
Best regards,
Aniket Chavan
🏆 ServiceNow MVP 2025 | 🌟 ServiceNow Rising Star 2024
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2025 04:38 AM
Hello,
I have tried with rich text label. it doesn't work for that type.
use 'reference" type and select user table for this.
write below catalog client script under catalog item :
Needed Person -- (needed_person) ----name of the reference field