Service catalog

garimakharb
Mega Guru

I have a rich text label field.  I have to populate the logged in user in this field. Its urgent anybody could help?

1 ACCEPTED SOLUTION

Aniket Chavan
Tera Sage
Tera Sage

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

  1. Navigate to Service Portal > Widgets and click "New".

  2. Give it a name like “Display User Greeting”.

  3. 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

  1. Open your catalog item or record producer.

  2. Under Variables, click New.

  3. Set the Type as “Custom”.

  4. In the Type Specifications, choose the widget you just created.

  5. 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

View solution in original post

10 REPLIES 10

Havishc
Tera Contributor

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 :

 

var d = g_user.getFullName();
    g_form.setValue('needed_person', d);

 

Needed Person --  (needed_person) ----name of the reference field